Skip to content

perf: Use ProgressIndicatorUtils.awaitWithCheckCanceled - #1649

Merged
angelozerr merged 1 commit into
redhat-developer:mainfrom
angelozerr:_ProgressIndicatorUtils.awaitWithCheckCanceled(
Aug 28, 2026
Merged

angelozerr merged 1 commit into
redhat-developer:mainfrom
angelozerr:_ProgressIndicatorUtils.awaitWithCheckCanceled(

Conversation

@angelozerr

@angelozerr angelozerr commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

CompletableFutures.waitUntilDone() polled future.get(25ms) in a tight loop while holding a ReadAction. When the LSP server was slow to respond, this blocked all pending WriteActions (document modifications, Git Push dialog, etc.), causing a cascade:

  1. ReadAction held → WriteAction blocked → EDT frozen
  2. LSP server can't process textDocument/didChange (needs WriteAction to update document) → server never responds
  3. Safety timeout fires → LSP feature returns empty → next request retries → same deadlock
  4. After enough timeouts → LSP server restarts → all pending requests lost

Fix

Replace all waitUntilDone() calls with ProgressIndicatorUtils.awaitWithCheckCanceled(future) — the correct IntelliJ API that cooperates with the ReadAction/WriteAction protocol:

  • When a WriteAction is requested, IntelliJ
  • awaitWithCheckCanceled detects the cancellation → throws ProcessCanceledException
  • ReadAction is released → WriteAction proce
  • IntelliJ reschedules the LSP feature automatically

Changes (51 files, -710 lines)

Core cleanup:

  • Deleted waitUntilDone() (3 overloads) —
  • Deleted PsiFileChangedException — only used by waitUntilDone, superseded by IntelliJ's ProgressIndicator
    cancellation on WriteAction
  • Deleted SafetyTimeoutException — only used by waitUntilDone
  • Rewrote waitUntilDoneAsync() to use ProCheckCanceled internally (used by renamehandler)

Migration (40 call sites):

  • All GoTo actions (definition, declaration,ion, reference)
  • Call hierarchy, type hierarchy (incoming, outgoing, subtypes, supertypes)
  • Code lens, inlay hints, folding range, sel
  • Completion, documentation, signature help, highlighting
  • Formatting, document symbol, document link
  • Semantic tokens, color provider
  • Workspace symbols, workspace implementatio
  • Code actions (intentions + quickfix)
  • File listeners, editor utils
  • DAP: debug process, completion, stepping, stack frame, disassembly, breakpoints
  • Inline completion (Kotlin)

Special case — WriteAction context:

  • LSPServerSideOnTypeFormattingHelper: uses future.get(500ms) directly (no ProgressIndicator in WriteAction, timeout is the guard)

@angelozerr
angelozerr force-pushed the _ProgressIndicatorUtils.awaitWithCheckCanceled( branch from c9bc6e0 to 510e9c1 Compare August 28, 2026 14:16
@angelozerr angelozerr changed the title Use ProgressIndicatorUtils.awaitWithCheckCanceled perf: Use ProgressIndicatorUtils.awaitWithCheckCanceled Aug 28, 2026
@angelozerr
angelozerr force-pushed the _ProgressIndicatorUtils.awaitWithCheckCanceled( branch from 510e9c1 to 8c95cf0 Compare August 28, 2026 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant