Skip to content

Go to Declaration holds the read lock while it waits for textDocument/definition, freezing the IDE #2015

Closed

Description

@lagergren

The freeze Report 2113215673533726720 in #2014 (LSP4IJ 0.21.0, IntelliJ IDEA 262.10968.63, at startup, IDE killed after 43 s, probable cause LONG_READ_ACTION) is a thread that waits for the reply to textDocument/definition while it holds the read lock:

ProgressIndicatorUtils.awaitWithCheckCanceled(ProgressIndicatorUtils.java:374)
LSPGotoDeclarationHandler.getGotoDeclarationTargets(LSPGotoDeclarationHandler.java:147)
LSPGotoDeclarationHandler.getGotoDeclarationTargets(LSPGotoDeclarationHandler.java:87)
GtdProvidersKt.fromGTDProvidersInner$lambda$0(gtdProviders.kt:42)
...
ApplicationImpl.runReadAction(ApplicationImpl.java:1119)
ActionUtil.underModalProgress$lambda$0(ActionUtil.kt:401)

Meanwhile the EDT waits for the write lock, so the IDE stays frozen until the server replies.

IntelliJ calls a GotoDeclarationHandler in a plain runReadAction under ActionUtil.underModalProgress. A write action that waits for the lock doesn't cancel that read action, so awaitWithCheckCanceled only returns when the server replies or the progress is cancelled.

In 0.30.0: unchanged. getGotoDeclarationTargets still waits at line 147, through CompletableFutures.awaitWithCheckCanceled, which 2a5d042 added to make the wait null-safe and which calls the same ProgressIndicatorUtils.awaitWithCheckCanceled. LSPDocumentLinkGotoDeclarationHandler waits the same way, at lines 75 and 139. I haven't reproduced the freeze on 0.30.0 yet.

Background: 0.20.1 bounded such waits to 2 s in a read action. #1648 removed the bound in 0.20.2, since it dropped the results of slow servers, and relies on a write action cancelling the progress, which doesn't happen in this caller.

Possible fix: bound the wait again where a write action can't cancel the read action, as here, and return no targets when the server takes longer.

Activity

  1. added
    bug
    on Nov 18, 2026
  2. lagergren commented on Nov 18, 2026

    @lagergren
    CollaboratorAuthor

    Reproduced on main (0bdec3f, 0.30.0) in IntelliJ IDEA 2026.3 (IU-263.7307.200). With a language server that answers textDocument/definition after 15 s, a write action (a VFS refresh) asked for 1.5 s after Go to Declaration started waited 13.7 s, until the server answered. Without a slow request, the same write action waits 1 to 74 ms.

    The UI thread kept responding here, since Go to Declaration runs under a modal progress, but everything that needs the write lock waits; in the report, the UI thread was the one waiting for it.

  3. added a commit that references this issue on Nov 18, 2026
    30cb393
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugdefinitionperformance

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions