[BUG] LSP: Roslyn language server crashes with BadRpcHeaderException on Windows (\r\n header issue)
Bug Description
The LSP tool fails with [Tool result missing due to internal error] when using roslyn-language-server (Microsoft's Roslyn LSP) on Windows. The root cause is a BadRpcHeaderException — the LSP client appears to send headers with \n line endings instead of the \r\n required by the LSP/JSON-RPC specification.
Steps to Reproduce
- Install the Roslyn language server as a .NET global tool:
``bash``
dotnet tool install --global Microsoft.CodeAnalysis.LanguageServer
- Configure
.lsp.jsonin the project root:
``json``
{
"csharp": {
"command": "roslyn-language-server.cmd",
"args": ["--stdio", "--autoLoadProjects", "--logLevel", "Information"],
"transport": "stdio",
"extensionToLanguage": {
".cs": "csharp",
".csx": "csharp"
},
"initializationOptions": {},
"settings": {},
"startupTimeout": 120000
}
}
- Use any LSP operation on a
.csfile:
````
LSP documentSymbol / hover / goToDefinition → [Tool result missing due to internal error]
Root Cause
Manual testing confirms the server starts but crashes immediately on the first message:
Content-Length: 116
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"[Program] Language server initialized"}}
Unhandled exception. StreamJsonRpc.BadRpcHeaderException: Header does not end with expected \r\n character sequence: ...
at StreamJsonRpc.HeaderDelimitedMessageHandler.ReadHeadersAsync(CancellationToken cancellationToken)
at StreamJsonRpc.HeaderDelimitedMessageHandler.ReadCoreAsync(CancellationToken cancellationToken)
The LSP specification requires \r\n as header delimiters. The StreamJsonRpc library used by Roslyn enforces this strictly.
Environment
- OS: Windows 11 Enterprise (10.0.22631)
- Claude Code: Latest (via Anthropic API)
- Language Server:
roslyn-language-serverv5.5.0 (Microsoft.CodeAnalysis.LanguageServer) - Shell: bash on Windows
Expected Behavior
LSP operations (hover, goToDefinition, documentSymbol, etc.) should work with the Roslyn language server.
Actual Behavior
All LSP operations return [Tool result missing due to internal error].
Related Issues
- #16360 — Missing protocol handlers with
csharp-ls(different server, different root cause) - #15914 —
.cmdextension not found on Windows (different root cause — server discovery vs. protocol)
Suggested Fix
Ensure the LSP client sends \r\n line endings in JSON-RPC headers per the LSP specification §Header Part. This is likely a single-line fix in the header serialization code.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗