Skip to content

fix: clear the problems of a stopped language server's files one after another, not with a read action for each at once - #2101

Merged
lagergren merged 1 commit into
redhat-developer:mainfrom
lagergren:fix/clear-the-problems-of-a-stopped-server-one-file-at-a-time
Nov 23, 2026
Merged

lagergren merged 1 commit into
redhat-developer:mainfrom
lagergren:fix/clear-the-problems-of-a-stopped-server-one-file-at-a-time

Conversation

@lagergren

Copy link
Copy Markdown
Collaborator

Fixes #2097

What

Stopping a language server that held 100 or more closed documents logged "Too many non-blocking read actions submitted at once". It now clears the problems of their files one file after another.

Cause

LanguageServerWrapper.stop passes all of its closed documents to LSPDiagnosticUtils.clearProblem. Since #1868, the clear's read action calls reportProblem for each file. Each report is a non-blocking read action coalesced by its file, so none of them merge: a clear of n files submitted n read actions at once, and IntelliJ's SubmissionTracker logs an error once 100 are active.

Change

The clear still resolves its files and asks the client's canReportProblem in one background read action. It then submits the report of the first file only:

  • When a report is processed, the report of the next file is submitted. A report is processed when it ran, when a later report of its file replaced it, or when it expired.
  • The chain stops once the project is disposed.
  • So a clear never has more than one report active.

onProcessed runs its callback at once if the report is already done, and otherwise on the thread that completes it, which can be the EDT. The callback therefore only hands the next report to a pooled thread. The chain never grows the stack, and the EDT never submits a report.

What #1868 needs is kept. Each report is still coalesced with the other reports of its file, and computes the mark from the errors held when it runs. A report of errors published since, submitted before or after the clear's report of the file, runs after it or replaces it.

reportProblem(VirtualFile, LSPDocumentBase, Project) keeps its public void signature. A new private method submits the report and returns its promise.

Test

ClosedDocumentProblemTest has two new tests:

  • testAServerThatStopsWithManyClosedDocumentsWithErrorsClearsTheirProblemsOneFileAfterAnother: a language server holding 150 closed documents with errors stops.
    • Its client holds each report until the clear has resolved all the files. A clear that submits a report per file as it resolves it then has them all active at once.
    • Errors logged on any thread are recorded.
    • The test expects every file's problem to be cleared, no error logged, and at most one report running at a time.
    • Without the fix, it fails with Too many non-blocking read actions submitted at once. ...: 11 with similar stack traces are currently active, and 148 reports run at once. With the fix, it passes.
  • testAFileWhoseErrorIsPublishedWhileAClearReportsAnEarlierFileStaysAProblemFileWhenTheClearReachesIt: a clear of three files is held at its report of the first file while an error is published for the second. Once the clear reaches the second file, that file must still be a problem file. It passes with and without the fix, and fails if the clear's reports ignore the errors held.

No test waits on time: the bounds only end a hang. Locally on 2024.2, the diagnostics tests and ClosedDocumentProblemTest pass (90 tests), and so does the full suite (1846 tests, 7 skipped: Windows-only and external-tool tests).

Not changed

Other loops submit a read action per file in the same way, and could log the same error with 100 or more files:

  • stop() disconnects each opened document with its own one-file clear;
  • LanguageServerWrapper.clearClosedDocumentDiagnostics(identifier) calls updateDiagnostics, and so reportProblem, for each closed document;
  • workspace diagnostic reports update one file at a time.

…r another, not with a read action for each at once

When a language server stops, the clear of its closed documents submitted a
report of each file at once, from one read action. With 100 or more files,
IntelliJ logs "Too many non-blocking read actions submitted at once".

The clear now submits the report of a file once the report of the file
before it is processed, from a pooled thread. Each report is still coalesced
with the other reports of its file, so a report of errors published since
runs after the clear's report of the file, or replaces it.
@lagergren lagergren added this to the 0.30.2 milestone Nov 22, 2026
@lagergren lagergren added bug Something isn't working diagnostic labels Nov 22, 2026
@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • Improved clearing of diagnostics for closed files. Reports are now cleared one file at a time, helping preserve newly published errors while older reports are being cleared.
    • Stopping a server now clears diagnostic marks across large numbers of closed files without producing logged errors.

clearProblem now submits problem reports for eligible files sequentially and stops when processing is complete or the project is disposed. New tests cover an error published during clearing and clearing problems for 150 closed files.

Changes: Diagnostic clearing

Layer / File(s) Summary
Sequential report submission and validation
src/main/java/com/redhat/devtools/lsp4ij/features/diagnostics/LSPDiagnosticUtils.java, src/test/java/com/redhat/devtools/lsp4ij/ClosedDocumentProblemTest.java
reportProblem delegates to a promise-returning helper. clearProblem filters eligible files and submits each report after the previous promise is processed. Tests verify that a new error remains reported during clearing and that clearing 150 closed files produces no logged errors or concurrent file-URI lookups.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: angelozerr

Merge Risk: Minimal · up to 8c5ab

Stopping a language server with many closed documents now clears their diagnostics one file at a time instead of submitting all the reads at once. That should avoid the "too many non-blocking read actions" error. No concrete defect was found, so the merge risk is minimal. One platform-behavior assumption about callback delivery on cancellation could not be verified against the IntelliJ 2024.2 artifacts.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title states the main change: when stopping a language server, the problems of its closed files are cleared one file after another instead of submitting one read action per file at once. This matc…
Description check Passed The description explains the cause (non-blocking read actions per file in the clear, triggering the SubmissionTracker error at 100 active), the change (sequential submission of per-file reports), the …
Linked Issues check Passed [#2097] The linked issue requires that a language server stop with 100+ closed documents does not submit one read action per file at once, and that per-file ordering from #1868 is kept. At the reviewe…
Out of Scope Changes check Passed All changes at the reviewed head serve #2097. In LSPDiagnosticUtils, the new submitProblemReport method, the reportProblemsOneAfterAnother chain, and the clearProblem change implement the sequential c…
Full details: Title check

Explanation

The title states the main change: when stopping a language server, the problems of its closed files are cleared one file after another instead of submitting one read action per file at once. This matches the raw summary, the description, and the objectives. The title is long (119 characters) but still specific and accurate.

Full details: Description check

Explanation

The description explains the cause (non-blocking read actions per file in the clear, triggering the SubmissionTracker error at 100 active), the change (sequential submission of per-file reports), the tests added, and the loops left unchanged. It is closely related to the changeset.

Full details: Linked Issues check

Explanation

[#2097] The linked issue requires that a language server stop with 100+ closed documents does not submit one read action per file at once, and that per-file ordering from #1868 is kept. At the reviewed head, LSPDiagnosticUtils.clearProblem runs one background read action that resolves the files and filters them with canReportProblem. It then calls reportProblemsOneAfterAnother, which submits only the first file's report (submitProblemReport). Each next report is submitted from onProcessed, on a pooled thread, after the previous report is processed. The chain stops when the project is disposed. Per-file ordering is kept: submitProblemReport still uses coalesceBy(LSP4IJ_REPORT_PROBLEM_SOURCE, file, project), and each report computes hasErrors when it runs. The public reportProblem signature is unchanged. The suggested validation (150 closed documents, problems cleared, no error logged) is covered by the new test named in the PR description, which the author reports passes. I did not run the tests. The test file was not inspected, so the test result rests on the author's report. The file diff was unavailable, so the change was read from the reviewed head file content.

Full details: Out of Scope Changes check

Explanation

All changes at the reviewed head serve #2097. In LSPDiagnosticUtils, the new submitProblemReport method, the reportProblemsOneAfterAnother chain, and the clearProblem change implement the sequential clear. The added imports and the clearProblem Javadoc support that change. The ClosedDocumentProblemTest additions, per the PR summary, cover the 150-document stop and the error published during a clear. These tests support the linked objective. No unrelated behavior change was found. The test file diff was not directly inspected, so this rests on the PR summary for the tests.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a600ec0b-e808-4081-af18-0b5562d07fa7
Commits

Reviewing files that changed from the base of the PR and between a82a94e and 8c5ab25.

Files selected for processing: 2

  • src/main/java/com/redhat/devtools/lsp4ij/features/diagnostics/LSPDiagnosticUtils.java
  • src/test/java/com/redhat/devtools/lsp4ij/ClosedDocumentProblemTest.java

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.

@codecov

codecov Bot commented Nov 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.43%. Comparing base (1b44654) to head (8c5ab25).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...sp4ij/features/diagnostics/LSPDiagnosticUtils.java 75.00% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2101      +/-   ##
==========================================
+ Coverage   50.34%   50.43%   +0.08%     
==========================================
  Files         816      816              
  Lines       33785    33825      +40     
  Branches     6962     6961       -1     
==========================================
+ Hits        17008    17058      +50     
+ Misses      14129    14122       -7     
+ Partials     2648     2645       -3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lagergren

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

lagergren added a commit to xtclang/xvm that referenced this pull request Nov 22, 2026
UP80 is fixed by our redhat-developer/lsp4ij#2096 and UP81 by our redhat-developer/lsp4ij#2101, both open for
0.30.2. xvm #741 lists them, with our other LSP4IJ pull requests for XTC since 0.30.0.
@lagergren

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@lagergren

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@lagergren

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@lagergren
lagergren merged commit cdb0a2b into redhat-developer:main Nov 23, 2026
9 checks passed
lagergren added a commit to xtclang/xvm that referenced this pull request Nov 25, 2026
UP80 is fixed by our redhat-developer/lsp4ij#2096 and UP81 by our redhat-developer/lsp4ij#2101, both open for
0.30.2. xvm #741 lists them, with our other LSP4IJ pull requests for XTC since 0.30.0.
lagergren added a commit to xtclang/xvm that referenced this pull request Nov 25, 2026
UP80 is fixed by our redhat-developer/lsp4ij#2096 and UP81 by our redhat-developer/lsp4ij#2101, both open for
0.30.2. xvm #741 lists them, with our other LSP4IJ pull requests for XTC since 0.30.0.
lagergren added a commit to xtclang/xvm that referenced this pull request Nov 25, 2026
UP80 is fixed by our redhat-developer/lsp4ij#2096 and UP81 by our redhat-developer/lsp4ij#2101, both open for
0.30.2. xvm #741 lists them, with our other LSP4IJ pull requests for XTC since 0.30.0.
lagergren added a commit to xtclang/xvm that referenced this pull request Nov 26, 2026
UP80 is fixed by our redhat-developer/lsp4ij#2096 and UP81 by our redhat-developer/lsp4ij#2101, both open for
0.30.2. xvm #741 lists them, with our other LSP4IJ pull requests for XTC since 0.30.0.
lagergren added a commit to xtclang/xvm that referenced this pull request Nov 26, 2026
UP80 is fixed by our redhat-developer/lsp4ij#2096 and UP81 by our redhat-developer/lsp4ij#2101, both open for
0.30.2. xvm #741 lists them, with our other LSP4IJ pull requests for XTC since 0.30.0.
lagergren added a commit to xtclang/xvm that referenced this pull request Nov 27, 2026
UP80 is fixed by our redhat-developer/lsp4ij#2096 and UP81 by our redhat-developer/lsp4ij#2101, both open for
0.30.2. xvm #741 lists them, with our other LSP4IJ pull requests for XTC since 0.30.0.
lagergren added a commit to xtclang/xvm that referenced this pull request Nov 28, 2026
UP80 is fixed by our redhat-developer/lsp4ij#2096 and UP81 by our redhat-developer/lsp4ij#2101, both open for
0.30.2. xvm #741 lists them, with our other LSP4IJ pull requests for XTC since 0.30.0.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working diagnostic

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stopping a language server that held 100 or more closed documents logs "Too many non-blocking read actions submitted at once"

1 participant