Skip to content

fix: completion freeze — resolve ↔ publishDiagnostics deadlock (port of redhat-developer/lsp4ij#1689) - #18

Merged
andreysubbotin merged 4 commits into
openide_0_21_0from
fix/completion-resolve-deadlock
Nov 6, 2026
Merged

andreysubbotin merged 4 commits into
openide_0_21_0from
fix/completion-resolve-deadlock

Conversation

@Artyom-Safronov

@Artyom-Safronov Artyom-Safronov commented Nov 6, 2026 •

Copy link
Copy Markdown

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/resolve in getExpensiveRenderer(); the response is queued on the messageWriter thread behind publishDiagnostics, where LSPLazyCodeActions takes a read action to find the PsiFile — and waits for the EDT. Since redhat-developer#1649 (0.20.2/0.21.0) that wait is awaitWithCheckCanceled, which nothing can cancel on the EDT, so the freeze is unbounded.

  • 9097d0b — cherry-pick of upstream e875835: LSPLazyCodeActions keeps a VirtualFile, no read action on the message thread.
  • db628f3 — cherry-pick of upstream ab03223: the selected item's detail is resolved inside the expensive renderer, off the EDT, for every server.

Tests: CompletionExpensiveRendererTest, LSPLazyCodeActionsTest pass. Full suite: 444, 7 failures in LSPIJUtils_applyWorkspaceEdit_* / CommandExecutorTest (File accessed outside allowed roots) — the same 7 fail on openide_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

halflifefan and others added 4 commits November 5, 2026 18:55
…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]>
@andreysubbotin
andreysubbotin merged commit ed10285 into openide_0_21_0 Nov 6, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants