Repository navigation
fix: a language server that fails to start no longer takes away the features of the file's other language servers - #2160
Merged
lagergren merged 1 commit intoNov 23, 2026
Conversation
…eatures of the file's other language servers A request for the language servers of a file starts each language server that serves the file, and connects the file to it, all in one CompletableFuture.allOf(). A language server that failed to start, as one with a wrong command or one that fails its initialize, failed allOf, and with it the whole request: a feature of the file then got none of its language servers, not even those that had started. Ctrl+hover, for instance, showed no hint. A request for the language servers of definitions, as for workspace symbols, or for LanguageServerManager.getLanguageServers(id) of a definition with several instances, had the same fault. A language server that fails to start, or to connect the file, is now left out of the request, and the other language servers serve it. When the request leaves out all of them, it still fails with the failure of the first one, as a request for a single language server did: a feature keeps no failed result, and asks again, as once the pause after a failed restart is over, while it would keep an empty one until the file changes. Nothing fails silently. A language server that cannot start, or that stopped, fails with a LanguageServerException, which it has reported already, with its "Cannot start server" notification and in the Language Servers view: it is logged at the debug level only. Any other failure of a language server that is left out is unexpected, and nothing else reports it: it is logged as a warning. A cancellation, as when the language server is stopped while the request waits for it, leaves it out without a failure, as before, and an Error still fails the request. Fixes redhat-developer#2158
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2160 +/- ##
==========================================
+ Coverage 53.23% 53.59% +0.35%
==========================================
Files 826 827 +1
Lines 34728 34956 +228
Branches 7147 5477 -1670
==========================================
+ Hits 18487 18733 +246
+ Misses 13470 13434 -36
- Partials 2771 2789 +18 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Collaborator
Author
|
@coderabbitai review |
Action not completed
|
Collaborator
Author
|
@coderabbitai review |
Action performed
|
lagergren
added a commit
that referenced
this pull request
Nov 23, 2026
…ion that it shuts down (#2162) ## What `CancelRequestAfterShutdownTest.testTheAnswerToARequestOfTheLanguageServerIsSentOnceTheShutdownIsSent`, which came with #2151, failed once on CI, on macOS 2024.2 (run [45231743923](https://github.com/redhat-developer/lsp4ij/actions/runs/45231743923), in #2160): The language server must read the answer to its request, and exit, after shutdown expected:<[shutdown, ResponseMessage, exit]> but was:<[shutdown, exit]> It's a bug in the test, not in LSP4IJ or #2151: LSP4IJ did answer the request, but over another connection. ## Cause - **A restart:** the test stops the language server while its editor is open. A stop that doesn't disable the language server lets a feature of the editor start it again, over a second connection (`start()` with the status `stopping`). The code vision does that when its first lookup of the language servers comes after the stop. - **The wrong client:** the mock language server then has two clients. The test sent `workspace/configuration` through the last of `getRemoteProxies()`, which was the new connection's, and that connection answered it. The connection that the test stops, and whose reads it checks, read only `shutdown` and `exit`. - **Reproduced:** under CPU load on macOS, with probes, main failed 2 of 2,100 runs. Each time, the second connection read the answer: [[initialize, initialized, didOpen, diagnostic, shutdown, exit], [initialize, ResponseMessage, initialized, didOpen, diagnostic, codeLens, $/cancelRequest]] With a 20 ms delay before the code vision's lookup of the language servers, 7 of 100 runs fail. Asking for the file's language servers right after the shutdown is read fails 20 of 20. ## Change - The test's connection keeps the client that it gives the language server. - The test sends the request through the client of the connection that it stops. - The test checks that the request ends with an answer: `isDone()` is also true for a request that couldn't be sent. ## Test - **With the fix:** 0 of 20 runs fail with the forced restart, and 0 of 100 with the delayed code vision (55 of them with two clients when the request was sent). - **`CancelRequestAfterShutdownTest`:** 8 tests, 0 failures, on IC 2024.2, IC 2025.3 and IU 2026.3. - **Full suite on IC 2024.2:** 2,134 tests, 0 failures, 0 errors, 7 skipped, as before.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2158
What
A request for the language servers of a file starts each matching language server, and connects the file to it, in one
CompletableFuture.allOf().initialize),allOffailed, and so did the whole request. The file lost the features of the language servers that had started too. Ctrl+hover on a working server's semantic tokens, for instance, showed no hint.LanguageServerManager.getLanguageServers(id)for a definition with several instances.Change
In
LanguageServiceAccessor, a language server of a request that fails to start, or to connect the file, is left out, and the others serve the request.LanguageServerException) has already been reported by the language server: the "Cannot start server" notification, and the Language Servers view. So it's logged at debug level only.Errorstill fails the request.handleFutureExceptionis unchanged:LanguageServerManager.getInitializedServer(wrapper), which waits for one server, still uses it.Behaviour change
Backward compatibility
Test
LSPSemanticTokenDocumentationProviderTest: Ctrl+hover gives the hint of the first server when the second fails itsinitialize.ServerStartFailureTest:LanguageServiceAccessor, the 6 new tests fail.com.redhat.devtools.lsp4ijand…features.*): 1,160 tests, 0 failures, on IC 2024.2, 2025.3 and IU 2026.3.