rust-lang / rust-lang/rust-analyzer

lsp-server: handle_shutdown crashing on response

Open
#19,077 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

Hello,

We are using your crate lsp-server in our project, and we face an issue when exiting the server.
There is a method that handle the shutdown Request from the client:
https://github.com/rust-lang/rust-analyzer/blob/3c2aca1e5e9fbabb4e05fc4baa62e807aadc476a/lib/lsp-server/src/lib.rs#L348

This method receive the shutdown request, then send the response and wait for the exit notification, sending an error if another message arrives.
But according to the lsp specification (https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#shutdown) , it is normal in my understanding that the client do not send any new Request after sending the shutdown request, but he could still send Responses to previous requests. ("If a server receives requests after a shutdown request those requests should error with InvalidRequest")
If that's the case, handle_shutdown is erroring, and we lose the responses we are still waiting.
We use the vscode client to develop our server, so I guess that receive Responses after the shutdown request is valid regarding the specifications.
We are thinking about modifying the line https://github.com/rust-lang/rust-analyzer/blob/3c2aca1e5e9fbabb4e05fc4baa62e807aadc476a/lib/lsp-server/src/lib.rs#L356C13-L356C25 , but we wanted to share this feedback with you and know what you think about that

Have a nice day

Contributor guide

Open the contributing guide

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

Start with handle_shutdown in lib/lsp-server/src/lib.rs around lines 348 and 356, then compare its message handling with the LSP 3.17 shutdown specification. Verify how responses to earlier requests are treated after shutdown, and define completion by preserving valid responses while handling later requests according to the specification.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
api, devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.