Repository navigation
Conversation
When the language server's process ended, for example because the server crashed on start, the client waited forever: LSP4J leaves a request pending if no response comes, and the wait for a file's diagnostics never looked at the process. Fail each request still pending when the process ends, through an endpoint that wraps the one LSP4J creates, and stop waiting for diagnostics once the process has ended. Both report the server's exit code. Add a test server that exits on start, when a document is opened, or when code actions are requested. Fixes ltex-plus#69. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Mv4cZ3LFVAJ9aG5SntwnAr
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 #69.
Problem
When the language server's process ends, for example because the server crashes on start, lsp-cli-plus waits forever: in
initialize().get(), or inChecker.checkFile's wait for a file's diagnostics. #69 has a reproduction.Cause
LSP4J leaves a request pending if no response comes, and nothing watched the server's process. The wait for a file's diagnostics didn't look at the process either.
Fix
LanguageServerProcessEndpointwraps theRemoteEndpointthat LSP4J creates and races each request againstProcess.onExit(). A request still pending when the process ends fails with the newLanguageServerExitedException, which carries the exit code.LspCliLanguageClientbuilds its server proxy over that endpoint withServiceEndpoints.toServiceObject, so this coversinitialize,textDocument/codeActionandshutdown.Checker's wait for a file's diagnostics throws once the process has ended.serverExitedWithExitCode.LspCliLauncher.runprints the stack trace and returns 1, as it does for other errors.changelog.xmlhas an entry.Not changed
A server that stays alive but never answers still makes the client wait. Only a timeout would catch that.
Testing
ExitingLanguageServerexits with code 42 on start, when a document is opened, or when code actions are requested.LanguageServerExitTestcovers the waits forinitialize, for diagnostics and for code actions, andLspCliLauncher.runreturning 1. Ondevelop, all 4 time out after 30 s. With the fix, each passes in 3 to 5 s.mvn verifypasses on JDK 21: 19 tests,ktlint,detektand JaCoCo.ltex-cli-plusrunning this build:cmd.exe /c exit 3Without #68, ltex-ls-plus 18.4.0 on JDK 25 still hangs when its standard error output goes to the client: the server blocks writing its stack trace to the pipe, so its process never ends. With both changes, the client fails at once.
Once #68 is merged too,
ExitingLanguageServerand #68'sStderrFloodingLanguageServercan share one helper inTestToolsfor their command lines.Drafted by Claude Opus 5.5 (
claude-opus-5-5); reviewed by @regulad.https://claude.ai/code/session_01Mv4cZ3LFVAJ9aG5SntwnAr