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

Documentation on LanguageClient lifecycle #48309

Closed
nrc opened this issue Apr 21, 2018 · 3 comments
Closed

Documentation on LanguageClient lifecycle #48309

nrc opened this issue Apr 21, 2018 · 3 comments
Assignees

Comments

@nrc
Copy link

nrc commented Apr 21, 2018

I've been looking for documentation on LanguageClient, but can't find any either in the source or online (there's lots of information on the language server, but not so much about using LanguageClient in the extension. In particular I'm looking for documentation on when/if I should be calling stop or other lifecycle functions.

My motivation here is to properly handle the language server restarting. I run the extension which starts the language server (the Rust Language Server). If I then kill the language server process, then the language server is restarted. However, I'm not clear what happens to the language client or the extension itself - I don't know if there hooks where I'm meant to handle stopping the client.

What happens is that the new language server gets two of every message, so it seems like there are now two clients sending messages to the same server (and if I keep killing the language server, I get n+1 messages after n restarts). I assume this is because I'm not handling something in the extension, but it could be a bug in VSCode itself.

@vscodebot
Copy link

vscodebot bot commented Apr 21, 2018

(Experimental duplicate detection)
Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

@jrieken jrieken assigned dbaeumer and unassigned jrieken Apr 23, 2018
@dbaeumer
Copy link
Member

@nrc agree that there is not a lot of documentation for the client itself except the source code and some examples here: https://github.com/Microsoft/vscode-extension-samples

Regarding your questions: you need to call stop in the deactivate method of your extension to stop the client which stops the server. When a server crashes the client restarts the server. It will not create a new instance of the server. You can control this behavior using the LanguageClientOptions#errorHandler property. If you see problems with server restarts please file a GitHub issue here: https://github.com/Microsoft/vscode-languageserver-node

@nrc
Copy link
Author

nrc commented Apr 23, 2018

Thanks @dbaeumer, it sounds like there are not lifecycle things that I am missing and that there might be a bug in the client. I filed microsoft/vscode-languageserver-node#342

@vscodebot vscodebot bot locked and limited conversation to collaborators Jun 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants