Repository navigation
fix: completion freeze — resolve ↔ publishDiagnostics deadlock (port of redhat-developer/lsp4ij#1689) - #18
Merged
Conversation
…c code actions textDocument/publishDiagnostics is handled on the language server's single message thread, and LSPLazyCodeActions resolved the PsiFile of the diagnosed file in its constructor through a cancellable read action. While the EDT holds a write action, that read action waits for it to finish. Since the message thread also delivers responses, an EDT waiting inside a write action for one of them (completionItem/resolve while typing, from LSPCompletionProposal#getExpensiveRenderer) can never get it, and the IDE freezes until it is killed. The PsiFile was only used to get back its VirtualFile for the textDocument/codeAction request, so keep the VirtualFile instead. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: halflifefan <[email protected]> (cherry picked from commit e875835)
… EDT LSPCompletionProposal#getExpensiveRenderer waited for completionItem/resolve of the selected item. IntelliJ calls getExpensiveRenderer() itself on the EDT, inside the write action of a typed character (LookupTypedHandler -> LookupImpl#updateList -> LookupCellRenderer#updateItemPresentation), and runs only the returned renderer in the background. Since awaitWithCheckCanceled has no cancelable indicator there, a slow server stalled typing, and a response stuck behind a message waiting for that write action froze the IDE for good. Return the renderer right away and resolve the detail in it, where the read action is canceled by the next write action. The resolve request is now created from both the EDT and background threads, so create it once. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: halflifefan <[email protected]> (cherry picked from commit ab03223)
…ed in the background now redhat-developer#1689 resolves the selected item's detail inside the expensive renderer, off the EDT, for every server. That is what the resolveDetailInBackground flag (9a4d7e3) switched on, so the flag and its separate renderer path in LSPCompletionProposal go away. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
IDE froze with an empty completion popup on LSP4IJ 0.21.0.1 (customer report, TypeScript; 0.19.4 was fine).
The EDT, inside the typing write action, waits for
completionItem/resolveingetExpensiveRenderer(); the response is queued on themessageWriterthread behindpublishDiagnostics, whereLSPLazyCodeActionstakes a read action to find thePsiFile— and waits for the EDT. Since redhat-developer#1649 (0.20.2/0.21.0) that wait isawaitWithCheckCanceled, which nothing can cancel on the EDT, so the freeze is unbounded.LSPLazyCodeActionskeeps aVirtualFile, no read action on the message thread.Tests:
CompletionExpensiveRendererTest,LSPLazyCodeActionsTestpass. Full suite: 444, 7 failures inLSPIJUtils_applyWorkspaceEdit_*/CommandExecutorTest(File accessed outside allowed roots) — the same 7 fail onopenide_0_21_0(814eae2).Checked in an OpenIDE sandbox with web-tools:
getExpensiveRenderer()inside a write action on the EDT with a resolve that never answers returns in 1 ms; a real item gets its detail in the background.🤖 Generated with Claude Code