-
Notifications
You must be signed in to change notification settings - Fork 273
Add support for automatic server restart on crash #1113
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
Conversation
17cdba6 to
86b298e
Compare
|
I haven't yet tried this out, but I will later (maybe tomorrow). The question I will be trying to answer: Let's say that the server crashes. I wrote an autocmd to handle Then after 3 retries, the server process comes back (maybe the user tapped a yubikey, maybe the network came back online, maybe a VPN reconnected, etc.) What information is available for me to know that I can overwrite the For example, I believe that LanguageServerStarted is emitted when the |
|
I believe this also implements the request in #993 |
|
Note that you can just use And yeah, as you said, the event is emitted when the client starts (it's also Good catch on that other issue! |
I am pretty sure you cannot currently do this. Maybe I'm reading the code wrong, but
it doesn't get set to zero when server spawns correctly at first and crashes later. |
oh never mind i see that it's now set in a third by this PR. let me try that out locally and see if it's enough |
7ab851d to
ab6474f
Compare
ab6474f to
4b2822f
Compare
|
@jez Spotted an issue with this, not critical though. When you manually want to stop the server by calling |

This PR adds support for automatic server restart retries on crash.
The way this is implemented it allows the user to specify whether or not to try to restart the server on crash via the option
LanguageClient_restartOnCrash(which defaults to 1). Additionally, the user can specify a max number of retries viaLanguageClient_maxRestartRetries(which applies for each languageId separately, and defaults to 5).The restarts follow a very naive exponential backoff, I could have added a new dependency on a library that implements a better backoff logic, but I think this simple approach should be enough.
Also, when a server crashes, the client will emit a new event
LanguageServerCrashed.Note that the attempted restart gets the current file name for the server initialisation, so if for example, your Go server crashes, but you are currently editing a JS file, things might go wrong.
Closes #1110, #320 and #774.