Smalls1652/mdatp-pwsh

Cancellation of authentication causes a process error for future close signals

Smalls1652 opened this issue · 0 comments

Problem

When using Ctrl+C anytime after the Connect-DatpGraph cmdlet is run, it causes the PowerShell process to crash.

(PS 7.1.1) [~]> Connect-DatpGraph
To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code [VerificationCode] to authenticate.
Connect-DatpGraph: A task was canceled.
(PS 7.1.1) [~]> Start-Sleep -Seconds 60

An error has occurred that was not properly handled. Additional information is shown below. The PowerShell process will exit.
Unhandled exception. System.ObjectDisposedException: The CancellationTokenSource has been disposed.
   at System.Threading.CancellationTokenSource.ThrowObjectDisposedException()
   at System.Threading.CancellationTokenSource.Cancel()
   at MdatpPwsh.Cmdlets.ConnectDatpGraph.cancelHandler(Object sender, ConsoleCancelEventArgs args)
   at System.Console.HandleBreakEvent(ConsoleSpecialKey controlKey)
   at System.ConsolePal.ControlCHandlerRegistrar.BreakEvent(Int32 controlType)

[process exited with code 3762504530]