You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A language server kept alive while its last-document stop is pending is still stopped #1834
When the last document of a language server is closed, LSP4IJ stops the server after lastDocumentDisconnectedTimeout (5 s by default), unless something keeps it alive. A keep-alive that starts during that wait doesn't keep it: the stop happens anyway. That covers a LanguageServerItem.keepAlive() lease taken during the wait, and LSPClientFeatures.keepServerAlive() starting to return true during it.
We hit this in XVM's IntelliJ plugin, whose run and debug sessions are hosted in the language server. A debug session started 0.2 s after the last Ecstasy file was closed. The server got shutdown 5.0 s after that file's didClose (16:41:03.673, then 16:41:08.677), which ended the session. The plugin now keeps the server with keepServerAlive() while a session runs, but a session started during the wait still loses it.
Cause
In LanguageServerWrapper (0.21.0, and main at e96dee9c):
maybeShutdown() checks keepAlive() once, when the last document disconnects. It then calls startStopTimer(), which sets the status to stopping and schedules stop() on the stop alarm.
The alarm's request calls stop() without checking keepAlive() again.
incrementKeepAlive(), which LanguageServerItem.keepAlive() calls, only increments keepAliveCounter.
start() and getInitializedServer() don't touch the alarm either, so a server that is used during the wait still stops, as expected without a lease.
So only connectDocument(...), which calls removeStopTimer(false), cancels a pending stop.
Expected
A server that is kept alive before the stop runs is not stopped. For example:
incrementKeepAlive() could cancel a pending stop, with removeStopTimer(false).
The alarm's request could check keepAlive() again before it calls stop(), and go back to started if it no longer applies.
The second also covers keepServerAlive(), which is a query, not an event.
Related: #1553 (the stopping status during the same wait), and #809 and #556 (keepServerAlive()).
Activity
fix: keep a language server kept alive while its last-document stop i…