csharp-language-server-protocol icon indicating copy to clipboard operation
csharp-language-server-protocol copied to clipboard

Server doesn't respond with ServerNotInitialized per spec

Open davidmatson opened this issue 4 years ago • 0 comments

According to the spec, if the server receives a request before initialize, it must send a response with error code -32002 (ServerNotInitialized). Failing to respond to a request also does not conform to JSON-RPC, which requires a response to every request.

Currently, LanguageServer just logs warnings:

OmniSharp.Extensions.LanguageServer.Server.LspServerReceiver: Warning: Unexpected request textDocument/formatting OmniSharp.Extensions.JsonRpc.Server.Request
OmniSharp.Extensions.LanguageServer.Server.LspServerOutputFilter: Warning: Tried to send request or notification before initialization was completed and will be sent later OmniSharp.Extensions.LanguageServer.Server.Messages.ServerNotInitialized

But does not send the appropriate error response.

To repro, run as a console app and paste the following text on startup:

Content-Type: application/vscode-jsonrpc; charset=utf-8
Content-Length: 72

{
"jsonrpc": "2.0",
"id": 1,
"method": "textDocument/formatting"
}

davidmatson avatar Jul 31 '21 02:07 davidmatson