Skip to content

Fix deadlock with inspect code - #535

Merged
pkwarren merged 2 commits into
mainfrom
pkw/fix-inspection-deadlock
Oct 9, 2026
Merged

pkwarren merged 2 commits into
mainfrom
pkw/fix-inspection-deadlock

Conversation

@pkwarren

@pkwarren pkwarren commented Oct 9, 2026

Copy link
Copy Markdown
Member

The buf plugin previously ran inspections through inspect code under a read lock (held by the platform) and performed
WriteAction.computeAndWait which couldn't complete while the read lock was held.

Update the inspection to record files to check in checkFile and then run inspections once per Buf context root in inspectionFinished (which is called without a read lock).

Adds a test which replicated the deadlock and now passes.

Fixes #534.

The buf plugin previously ran inspections through inspect code under a
read lock (held by the platform) and performed
`WriteAction.computeAndWait` which couldn't complete while the read lock
was held.

Update the inspection to record files to check in `checkFile` and then
run inspections once per Buf context root in `inspectionFinished` (which
is called without a read lock).

Adds a test which replicated the deadlock and now passes.

Fixes #534.
val isBufDocument = { document: Document -> fileDocumentManager.getFile(document)?.isBufFile() == true }
if (fileDocumentManager.unsavedDocuments.any(isBufDocument)) {
WriteAction.computeAndWait<Unit, Throwable> {
fileDocumentManager.saveDocuments(isBufDocument)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still save files here since the buf CLI runs against files on disk but we only do so if .proto files or buf config files change instead of if any files changed.

@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Qodana Community for JVM

It seems all right 👌

No new problems were found according to the checks applied

💡 Qodana analysis was run in the pull request mode: only the changed files were checked

View the detailed Qodana report

To be able to view the detailed Qodana report, you can either:

To get *.log files or any other Qodana artifacts, run the action with upload-result option set to true,
so that the action will upload the files as the job artifacts:

      - name: 'Qodana Scan'
        uses: JetBrains/qodana-action@v2026.2.2
        with:
          upload-result: true
Contact Qodana team

Contact us at qodana-support@jetbrains.com

@pkwarren
pkwarren merged commit a4d310e into main Oct 9, 2026
9 checks passed
@pkwarren
pkwarren deleted the pkw/fix-inspection-deadlock branch October 9, 2026 16:12
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.

Plugin causes IntelliJ to completely freeze up when running code inspections

3 participants