-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lsp-server: handle_shutdown crashing on response #19077
Comments
Why does it matter if we ignore the responses? We're shutting down anyway. Is the error the problem? |
Yes, it means we do not handle the exit notification and leave this method with an error, instead of really handle the exit notification. So the method is not really doing what it it designed to do, and send a ProtocolError where there is not. |
So to clarify, the issue is that the receiver there might receive a |
Indeed, that's what we are doing on our side. Indeed an easy fix would be to loop and discard responses, but it would prevent the server from effectively react to these responses, but that issue depends on the needs of the server. In our case we integrated the shutdown behaviour to our main loop because we want to handle Responses even in shutdown process. From my point of view, I guess that "handle_shutdown" is more an "example" on how to handle shutdown and maybe shouldn't be used in production, but then it would nice that it reflects this behaviour |
Ah right, server to client requests exist as well (forgot about that since rust-analyzer doesn't make use of that). Yes I think that method only really exists as an example (being used in our one example as well). I believe it might be best to remove it (or well inline it into our example, and add a comment) as proper handling seems to be project specific. |
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:
rust-analyzer/lib/lsp-server/src/lib.rs
Line 348 in 3c2aca1
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
The text was updated successfully, but these errors were encountered: