Skip to content

Fix server crash when launched without console#1774

Merged
belav merged 2 commits intobelav:mainfrom
rcdailey:fix/server-console-readkey-crash
Dec 13, 2025
Merged

Fix server crash when launched without console#1774
belav merged 2 commits intobelav:mainfrom
rcdailey:fix/server-console-readkey-crash

Conversation

@rcdailey
Copy link
Copy Markdown
Contributor

Summary

  • Remove Console.ReadKey() in ServerFormatter.cs which throws InvalidOperationException when CSharpier server is started by IDE plugins (Rider, VS, VSCode) without a console attached
  • The call was unreachable during normal operation since RunAsync() blocks until shutdown

Problem

When IDE plugins launch csharpier server, the process crashes immediately with:

System.InvalidOperationException: Cannot read keys when either application does not have a console or when console input has been redirected.
   at System.ConsolePal.ReadKey(Boolean intercept)
   at CSharpier.Cli.Server.ServerFormatter.StartServer(...)

This manifests in Rider as "Process exited unexpectedly" errors.

rcdailey and others added 2 commits December 12, 2025 22:23
Remove Console.ReadKey() which throws InvalidOperationException when
CSharpier server is started by IDE plugins (Rider, VS, VSCode) without
a console attached. The call was unreachable during normal operation
since RunAsync() blocks until shutdown.
Copy link
Copy Markdown
Owner

@belav belav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this. I wonder if this was the cause of csharpier server not working for some folks. I could never reproduce the issue locally.

@belav belav added this to the 1.2.2 milestone Dec 13, 2025
@belav belav enabled auto-merge (squash) December 13, 2025 16:48
@belav belav merged commit ada2305 into belav:main Dec 13, 2025
7 checks passed
@rcdailey rcdailey deleted the fix/server-console-readkey-crash branch February 23, 2026 15:41
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

Successfully merging this pull request may close these issues.

2 participants