Skip to content

Headless, a language server that sends $/progress hangs: the progress task runs in the thread that reads its messages #2342

Done

Description

@lagergren

Version: main at 7c6d061. The code dates from the $/progress support (83a5729, 2024-03-31), so every release has it.

What happens

In a headless application, as in the tests of a plugin built on LSP4IJ or a headless run of the IDE, a language server that sends $/progress stalls its own connection: LSP4IJ reads no further message from it, so every request to it waits forever.

LanguageClientImpl.notifyProgress is called on the LSP4J thread that reads the messages of the language server. It calls LSPProgressManager.notifyProgress, whose createTask starts the progress with ProgressManager.getInstance().run(new Task.Backgroundable(...)). With a UI, the platform runs that task on a pooled thread. Headless, it runs it synchronously in the calling thread (CoreProgressManager.runProcessWithProgressInCurrentThread). The task loops on LSPProgressInfo.getNextProgressNotification() until the progress ends, but the report and end notifications can only be read by the thread that now runs the loop.

The reading thread, from a thread dump of such a hang:

"LS-…#listener-0" TIMED_WAITING
	at java.util.concurrent.LinkedBlockingDeque.pollFirst(LinkedBlockingDeque.java:515)
	at com.redhat.devtools.lsp4ij.features.progress.LSPProgressInfo.getNextProgressNotification(LSPProgressInfo.java:69)
	at com.redhat.devtools.lsp4ij.features.progress.LSPProgressManager$1.run(LSPProgressManager.java:107)
	at com.intellij.openapi.progress.impl.CoreProgressManager.startTask(CoreProgressManager.java:477)
	…
	at com.intellij.openapi.progress.impl.CoreProgressManager.runProcessWithProgressInCurrentThread(CoreProgressManager.java:613)
	at com.intellij.openapi.progress.impl.CoreProgressManager.run(CoreProgressManager.java:410)
	at com.redhat.devtools.lsp4ij.features.progress.LSPProgressManager.createTask(LSPProgressManager.java:86)
	at com.redhat.devtools.lsp4ij.features.progress.LSPProgressManager.notifyProgress(LSPProgressManager.java:210)
	at com.redhat.devtools.lsp4ij.client.LanguageClientImpl.notifyProgress(LanguageClientImpl.java:433)
	…
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleNotification(RemoteEndpoint.java:225)

Meanwhile the highlighting passes wait in CompletableFutures.awaitWithCheckCanceled for semantic tokens, folding ranges, code lenses, inlay hints and document links.

Steps

  1. In a headless test with a heavy project fixture, define gopls 0.24.0 as a user-defined language server for *.go, on a module with a main.go.
  2. Open main.go and call doHighlighting().

Expected: the highlighting gets the answers of gopls, as it does with clangd or zls, which send no $/progress at start.

Actual: doHighlighting() never returns; the suite's hang watchdog reports it after 300 s. With notifyProgress overridden to do nothing in the language client, the same test passes in 7 s. rust-analyzer (212 $/progress notifications for a small Cargo project), jdtls (34) and typescript-language-server (2) send it too.

Where we saw it: checking semantic tokens with real language servers for #2338.

A possible fix: never run the task in the reading thread, for example by starting it from a pooled thread, or with ProgressManager.runProcessWithProgressAsynchronously, which runs it on a pooled thread also when headless.

Activity

  1. added
    bug
    $/progress
    and removed
    $/progress
    on Nov 28, 2026
  2. added this to the 0.30.3 milestone on Nov 28, 2026
  3. added a commit that references this issue on Nov 30, 2026
    628f790
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

    $/progressbug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions