OmniSharp / OmniSharp/csharp-language-server-protocol

Server doesn't respond with ServerNotInitialized per spec

Open
#628 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
638
Forks
109
Avg merge
1m
Merged PRs (30d)
2

Description

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"
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue by running the server as a console app and sending the provided textDocument/formatting request before initialization. Inspect LanguageServer, LspServerReceiver, and LspServerOutputFilter, then verify that every pre-initialize request receives a JSON-RPC error response with code -32002 (ServerNotInitialized) rather than only warnings.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend-api-design
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.