Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unhandled exception in ConsolePal.ReadKey #1099

Closed
edyoung opened this issue Oct 11, 2018 · 7 comments
Closed

Unhandled exception in ConsolePal.ReadKey #1099

edyoung opened this issue Oct 11, 2018 · 7 comments

Comments

@edyoung
Copy link

edyoung commented Oct 11, 2018

Steps to reproduce

I don't have a consistent repro, sorry. See version details below. Typed c space d backspace backspace, pwsh hung for about 10 seconds then produced error below and exited

PS C:\onebranch> c
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.PSConsoleReadLine.ReadOneOrMoreKeys()
   at Microsoft.PowerShell.PSConsoleReadLine.ReadKeyThreadProc()
   at System.Threading.Thread.ThreadMain_ThreadStart()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

Expected behavior

Don't crash

Environment data

> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      6.1.0
PSEdition                      Core
GitCommitId                    6.1.0
OS                             Microsoft Windows 10.0.17763
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
@iSazonov
Copy link

We need repo.

@SteveL-MSFT
Copy link
Member

Can you open this in the PSReadLine repo? PSConsoleReadLine is coming from PSReadLine

@iSazonov
Copy link

@daxian-dbw Could you please make a conclusion about the issue while you is on the wave?

@SteveL-MSFT SteveL-MSFT transferred this issue from PowerShell/PowerShell Oct 14, 2019
@daxian-dbw
Copy link
Member

@iSazonov I cannot. I cannot reproduce this, and the reported exception was thrown from the .NET Core code. Hope it's fixed in the .NET Core 3.0

@iSazonov
Copy link

https://stackoverflow.com/questions/46901071/readkey-not-working-in-net-core/46952718
https://stackoverflow.com/questions/6064989/running-a-windows-service-in-console-mode
dotnet/vscode-csharp#1746

They say that it is terminal issue. I guess VS Code terminal.

We could close the issue until we get stable repo.

@daxian-dbw
Copy link
Member

Close the issue because

  1. cannot reproduce the issue
  2. exception is thrown from System.Console.ReadKey, which is .NET Core code.

@jazzdelightsme
Copy link
Contributor

This problem could be caused by: dotnet/runtime#88697

I plan to open a new Issue for how this could be addressed in PSReadLine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants