-
Notifications
You must be signed in to change notification settings - Fork 106
Potential race condition with initialized handler #588
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
Comments
It could certainly explain my issue. I think I can add logging for the "Unexpected request" events in my repro. If I see that logged for legitimate LSP requests/notifications, it would confirm the hypothesis. |
So the naming is wrong (more specifically it was never changed). What is happening is that in lsp v2, the server and client was assumed to be ready for everything immediately after the As I'm typing this, it's entirely possible that I'm reading or understanding it wrong, and simply moving the |
Today there are three different hooks in the setup process (perhaps confusingly)
If you have any logic in |
We initially were looking into our server -> client calls, but I think our issue is actually coming from a client call to the server. Another example of a request we were seeing fail here was when we send a custom request at startup to query the PowerShell version being used, here. We were worried that this It turns out that Essentially, we think there's some period of time in O# after the |
I think this is the right move. The spec is a bit hard to understand, but first there's the
This is fine, our client (which just uses Secondly, there's the
Ok, great, but this is annoying! Our client has sent
In our case, we're depending on "Unexpected notification workspace/didChangeConfiguration" and "Unexpected request powerShell/getVersion" to actually be processed correctly, as they are not supposed to be unexpected since they were sent by the client after it sent its initialized notification. |
Can't wait to try this out! ❤ |
|
Yay!!! Awesome to hear @majastrz. |
So @rjmholt and I have been debugging an issue with the PowerShell extension after updating to v3.19, and we believe have tracked it down to a race condition. But we don't know if this is an issue with OmniSharp, or maybe even with the LSP spec itself.
We see that the
Initialize
request handler, for LSP2, setsInitialized
:csharp-language-server-protocol/src/Server/LanguageServer.cs
Lines 316 to 322 in 005c87f
This made sense, because
Initialize
was a request and so the client can (and does) wait to hear from the server thatInitialize
was handled. When OmniSharp calls thatinitialized()
method (for LSP2) thenGetRequests()
starts behaving "correctly" (handling all notifications and requests):csharp-language-server-protocol/src/Server/LspServerReceiver.cs
Lines 20 to 54 in 1b6788d
But then this was changed for LSP3, we have an
Initialized
(note the D) handler for theInitialized
notification (which the client cannot wait on). This is problematic because the client then sends more notifications which race the server's handler for theInitialized
notification, and this race ends up in the requests not being handled, as evidenced by the responses "Unexpected request" and "Unexpected notification" inGetRequests
.csharp-language-server-protocol/src/Server/LanguageServer.cs
Lines 327 to 337 in 005c87f
This correlates with the logs we have when we see a bug in the PowerShell extension:
We think this may be related to #556, @david-driscoll was there any update on your investigation into that issue? @majastrz does any of this make sense to you and sound related to your issue?
The text was updated successfully, but these errors were encountered: