Repository navigation
Closed
Description
Environment
- LSP4IJ 0.21.0
- PyCharm 2026.1 (build PY-261.22158.340), Linux
- Language server: RobotCode, which registers
workspace.fileOperations.willDelete(andwillCreate/willRename) with a glob filter for its file types
What happens
The IDE froze for more than 10 minutes until the process was killed. The freeze report shows a lock cycle between the EDT and LSP4IJ's messageWriter thread:
- A VFS refresh (here the initial refresh after opening the project) fires its events in a write action, which is transferred to the EDT. In
beforeVfsChange,AbstractLSPFileListener.beforesendsworkspace/willDeleteFilesfor a matching file and waits for the result inapplyWorkspaceEditwithProgressIndicatorUtils.awaitWithCheckCanceledon the EDT, without a progress indicator or timeout, while the write action is held. LanguageServerWrapperpasses every message, incoming and outgoing, toCompletableFuture.runAsync(..., messageWriter), andmessageWriteris a single-thread executor (LanguageServerWrapper.java:478).- At the same moment the
messageWriterthread is handling an incomingtextDocument/publishDiagnostics.LSPDiagnosticsForServer.toMapcreatesLSPLazyCodeActions, whose constructor callsLSPIJUtils.getPsiFile, which runs a non-blocking read action synchronously. That read action waits until the write action of step 1 ends. - The outgoing
willDeleteFilesrequest is queued behind this notification on the same executor, so it is never sent. The server never answers, and the EDT never gets its result. Later messages stay queued as well: the progress of the server's startup analysis never ended in the status bar, while the server process was idle.
Thread dump excerpts
EDT:
at com.intellij.openapi.progress.util.ProgressIndicatorUtils.awaitWithCheckCanceled(ProgressIndicatorUtils.java:387)
at com.redhat.devtools.lsp4ij.features.files.AbstractLSPFileListener.applyWorkspaceEdit(AbstractLSPFileListener.java:248)
at com.redhat.devtools.lsp4ij.features.files.AbstractLSPFileListener.before(AbstractLSPFileListener.java:229)
at com.redhat.devtools.lsp4ij.features.files.AbstractLSPFileListener$1.beforeVfsChange(AbstractLSPFileListener.java:87)
at com.intellij.openapi.vfs.newvfs.AsyncEventSupport.invokeAppliers(AsyncEventSupport.java:171)
...
at com.intellij.openapi.application.impl.TransferredWriteActionServiceImpl.runOnEdtWithTransferredWriteActionAndWait$lambda$0(TransferredWriteActionServiceImpl.kt:11)
Refresh thread (holds the write action and waits for the EDT):
at com.intellij.openapi.application.impl.InternalThreading$TransferredWriteActionEvent.blockingWait(appImpl.kt:252)
at com.intellij.openapi.vfs.newvfs.AsyncEventSupport.processEventsFromRefresh(AsyncEventSupport.java:190)
at com.intellij.openapi.vfs.newvfs.RefreshSessionImpl.fireEventsInWriteAction(RefreshSessionImpl.kt:277)
LS-<server>#messageWriter:
at com.intellij.openapi.application.impl.NonBlockingReadActionImpl$Submission.blockUntilWriteActionIsDone(NonBlockingReadActionImpl.java:710)
at com.intellij.openapi.application.impl.NonBlockingReadActionImpl.executeSynchronously(NonBlockingReadActionImpl.java:295)
at com.redhat.devtools.lsp4ij.internal.ApplicationUtils.runCancellableReadAction(ApplicationUtils.java:59)
at com.redhat.devtools.lsp4ij.LSPIJUtils.getPsiFile(LSPIJUtils.java:570)
at com.redhat.devtools.lsp4ij.features.codeAction.quickfix.LSPLazyCodeActions.<init>(LSPLazyCodeActions.java:77)
at com.redhat.devtools.lsp4ij.features.diagnostics.LSPDiagnosticsForServer.toMap(LSPDiagnosticsForServer.java:170)
...
at com.redhat.devtools.lsp4ij.client.LanguageClientImpl.publishDiagnostics(LanguageClientImpl.java:122)
...
at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:192)
at com.redhat.devtools.lsp4ij.LanguageServerWrapper.lambda$start$7(LanguageServerWrapper.java:478)
When it can happen
Whenever a server registers willDelete, willCreate or willRename, a matching file is deleted, created or renamed (the listener runs in the write action of the VFS change, whether it comes from a refresh or from the user), and a publishDiagnostics from the same server is being handled at that moment. Servers that publish diagnostics for many files after startup make this likely right after a project is opened.
Possible directions
- Do not wait for the server on the EDT while a write action is held, or bound the wait with a timeout so that the file operation goes ahead without the edit.
- Do not run blocking read actions on the thread that also sends outgoing messages, or use separate executors for incoming and outgoing messages, so that a request can always be sent.
Metadata
Metadata
Assignees
Labels
bugSomething isn't working
Type
Projects
- StatusShow more project fieldsDone
Activity
fix(language-server): don't freeze PyCharm and IntelliJ when Robot fi…
angelozerr commentedon Oct 11, 2026
I think #1689 could fix your issue.
Could you please install https://github.com/redhat-developer/lsp4ij#testing-nightly-builds and telll me if it fixes your issue
d-biehl commentedon Oct 11, 2026
Thanks! I tested the nightly 0.21.1-20261011-014957, and it fixes the freeze for us.
Setup in PyCharm 2026.1 (PY-261.22158.340) with the RobotCode language server: a project with 150 suites that each get a diagnostic, workspace diagnostics on, and 20 of the suites open in editors. A script deleted 40 matching files through the VFS, one every 50 ms, and before every second deletion saved a resource file that all suites import, so the server kept publishing diagnostics for the open documents.
AbstractLSPFileListener.applyWorkspaceEdit, andmessageWriterinLSPLazyCodeActions.<init>→LSPIJUtils.getPsiFile.willDeleteFiles, and the EDT waited 7 ms in the median and 52 ms at most per deletion. No errors in idea.log.What remains is that the EDT still waits for the
willDeleteFilesanswer inside the write action without a timeout. A slow server still blocks the UI for that time, and another blocking read action on the message thread could bring the cycle back. Feel free to close this issue if you'd rather track that separately.Do you already have a rough idea when the next LSP4IJ release with this fix will be out?
angelozerr commentedon Oct 12, 2026
That's super great!
Great!
You mean that we should improve this usecase?
There are some few issues that we need to finish and I hope I will create the release soon.
angelozerr commentedon Oct 12, 2026
Fixed with #1689
angelozerr commentedon Oct 12, 2026
@d-biehl could you please test #1695 and give me feedback.
See https://github.com/redhat-developer/lsp4ij#testing-the-ci-builds how to test a PR with build zip
fix: move workspace/will* requests off EDT to prevent UI freezes
fix: move workspace/will* requests off EDT to prevent UI freezes
d-biehl commentedon Oct 12, 2026
Yes, I meant the wait for the answer without a limit.
I tested #1695 (build zip
0.21.1-SNAPSHOTfrom d4514d1). The freeze reproduction from before ran 3 × 40 deletions without a freeze: per deletion the EDT waited 12 ms in the median and 82 ms at most, the server answered all 120willDeleteFilesrequests, and idea.log had no errors.To see what #1695 changes, I let the server answer
willDeleteFilesonly after a delay:willDeleteFilesrequests for the file, and it was gone from the VFS only after 35 sVirtualFile.delete()in a write action on the EDT, as the Project view's Delete does)Deletions outside the IDE. Could it be that LSP4IJ shouldn't send
willDeleteFileshere at all? It sends it when git, a terminal or another tool deletes files and the VFS refresh picks that up; at startup it even sent it for 40 files that had been deleted while the IDE was closed. As I read the specification, the request is meant only "as long as the deletion is triggered from within the client either by a user action or by applying a workspace edit", and in these cases the files are already gone from the disk. VS Code doesn't fire it there either: its API documentation forworkspace.onWillDeleteFilessays the event is triggered by user gestures orworkspace.applyEdit, "but this event is not fired when files change on disk, e.g triggered by another application".With #1695 the request is still sent in this case. It no longer blocks the UI, but it is sent again whenever the user edits a file while LSP4IJ waits for the answer (each edit restarts
prepareChange). In my test, five edits during the wait led to 11 requests for the same file, and the file disappeared from the IDE only 30 s after the last edit.Deletions inside the IDE, the case
willDeleteFilesis meant for, don't change with #1695: the write action on the EDT still waits untilprepareChangehas returned, so the UI blocks for however long the server takes to answer. The specification allows clients to drop results "if computing the edit took too long or if a server constantly fails on this request. This is done to keep deletes fast and reliable." VS Code limits the wait with the settingfiles.participants.timeout, "Timeout in milliseconds after which file participants for create, rename, and delete are cancelled. Use0to disable participants." (default 60000), and while it waits it shows a cancellable notification "Running 'File Delete' participants..." after at most 3 seconds.willCreateFilesandwillRenameFilesare sent from the same place in LSP4IJ, so they might behave the same; I haven't tested them.angelozerr commentedon Oct 12, 2026
@d-biehl please retry #1695
d-biehl commentedon Oct 15, 2026
I retested the current state of #1695 with the reproduction from this issue; the results are in #1695 (comment). The freeze is gone, and it works for us like this for now.