Skip to content
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

handleInitialize tries to register capabilities prematurely #26

Closed
vytautassurvila opened this issue Mar 29, 2022 · 2 comments
Closed

Comments

@vytautassurvila
Copy link
Contributor

When csharp-language-server is used with vscode-languageclient then client crashes with error Unhandled method client/registerCapability. If I read code right culprit is in following two lines

let! regResult = lspClient.ClientRegisterCapability(
{ Registrations = [| didChangeWatchedFilesRegistration |] })
Those do send client/registerCapability to client immediately before emitting initialize result.

According to Lsp initialize request

In addition the server is not allowed to send any requests or notifications to the client until it has responded with an InitializeResult, with the exception that during the initialize request the server is allowed to send the notifications window/showMessage, window/logMessage and telemetry/event as well as the window/showMessageRequest request to the client

https://microsoft.github.io/language-server-protocol/specification#initialize

In order to register dynamic capabilities initialized notification should be used instead:

The server can use the initialized notification for example to dynamically register capabilities

https://microsoft.github.io/language-server-protocol/specification#initialized

And the vscode-languageclient code that starts listening on client/registerCapability only after successful initialization (first and last lines are relevant) https://github.com/microsoft/vscode-languageserver-node/blob/d9eeaf626fd9362eec69fe63322d15760f6794d1/client/src/common/client.ts#L3402-L3430

@razzmatazz
Copy link
Owner

should be fixed with 333f9f4

releasing 0.4.2 in a moment..

@vytautassurvila
Copy link
Contributor Author

Thanks, vscode-languageclient does not crash anymore with 0.4.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants