Unhandled exception. System.InvalidOperationException: Cannot read keys when either application does not have a console or when console input has been redirected #6952

Open
opened 2026-01-31 00:51:24 +00:00 by claunia · 0 comments
Owner

Originally created by @SergioMorchon on GitHub (Mar 18, 2020).

Environment

Windows build number: Win32NT, 10.0.18363.0, Microsoft Windows NT 10.0.18363.0:

Steps to reproduce

Using:

  1. I start the dev server and leave it run in this terminal.
  2. After some time of working between vscode and the web browser.
  3. I come back to the console and hit Ctrl+C to stop the process and do other stuff.

Expected behavior

To behave as a normal Ctrl+C, and continue using the same terminal tab.

Actual behavior

It shows an exception:

PS C:\Users\smorchon\dev\webapp\web>
An error has occurred that was not properly handled. Additional information is shown below. The PowerShell process will
exit.
Unhandled exception. System.InvalidOperationException: Cannot read keys when either application does not have a console
or when console input has been redirected. Try Console.Read.
   at System.ConsolePal.ReadKey(Boolean intercept)
   at System.Console.ReadKey(Boolean intercept)
   at Microsoft.PowerShell.Internal.VirtualTerminal.ReadKey()
   at Microsoft.PowerShell.PSConsoleReadLine.ReadOneOrMoreKeys()
   at Microsoft.PowerShell.PSConsoleReadLine.ReadKeyThreadProc()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object
state)
--- End of stack trace from previous location where exception was thrown ---
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object
state)
   at System.Threading.ThreadHelper.ThreadStart()

[process exited with code 3762504530]

And after that, I can only close that terminal tab and continue un a new one.

Originally created by @SergioMorchon on GitHub (Mar 18, 2020). # Environment ``` Windows build number: Win32NT, 10.0.18363.0, Microsoft Windows NT 10.0.18363.0: ``` # Steps to reproduce Using: * pwsh `v7.0.0`. * [yarn|https://yarnpkg.com/] `v1.22.0`. * [node|https://nodejs.org/en/] `v12.16.1`. * [webpack dev server|https://webpack.js.org/configuration/dev-server/] `3.9.0`. 1. I start the dev server and leave it run in this terminal. 1. After some time of working between vscode and the web browser. 1. I come back to the console and hit `Ctrl+C` to stop the process and do other stuff. # Expected behavior To behave as a normal `Ctrl+C`, and continue using the same terminal tab. # Actual behavior It shows an exception: ``` PS C:\Users\smorchon\dev\webapp\web> An error has occurred that was not properly handled. Additional information is shown below. The PowerShell process will exit. Unhandled exception. System.InvalidOperationException: Cannot read keys when either application does not have a console or when console input has been redirected. Try Console.Read. at System.ConsolePal.ReadKey(Boolean intercept) at System.Console.ReadKey(Boolean intercept) at Microsoft.PowerShell.Internal.VirtualTerminal.ReadKey() at Microsoft.PowerShell.PSConsoleReadLine.ReadOneOrMoreKeys() at Microsoft.PowerShell.PSConsoleReadLine.ReadKeyThreadProc() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location where exception was thrown --- at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() [process exited with code 3762504530] ``` And after that, I can only close that terminal tab and continue un a new one.
claunia added the Needs-Tag-FixResolution-No-ReproNeeds-AttentionNeeds-Repro labels 2026-01-31 00:51:24 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#6952