Skip to content

fix: pull workspace diagnostics again when the server cancels a pull itself - #2029

Merged
lagergren merged 1 commit into
redhat-developer:mainfrom
lagergren:fix/workspace-diagnostic-server-cancel
Nov 20, 2026
Merged

lagergren merged 1 commit into
redhat-developer:mainfrom
lagergren:fix/workspace-diagnostic-server-cancel

Conversation

@lagergren

Copy link
Copy Markdown
Collaborator

Fixes #2027

LSP4J answers RequestCancelled for any request whose future a server cancels, so a server built on LSP4J cannot answer ServerCancelled for a workspace pull it cancels itself. WorkspaceDiagnosticManager took that answer as a failure and stopped pulling until the next refresh.

A pull that LSP4IJ cancels completes at once with a CancellationException, and a late answer to it is ignored, so a RequestCancelled answer that reaches shouldRetrigger comes from the server. It now starts a new pull, as ServerCancelled without data does. Other errors still stop the pulls until the next refresh or registration.

Tests

WorkspaceDiagnosticManagerTest:

  • retriesAPullTheServerCancelledItself: after a RequestCancelled answer, the next pull comes, with the previous result IDs. It fails without the fix.
  • stopsAfterAFailedPull: an InternalError still stops the pulls until a refresh.

The diagnostic tests (--tests '*Diagnostic*'): 83 tests, 0 failures.

…itself

Fixes redhat-developer#2027

LSP4J answers RequestCancelled for any request whose future a server cancels, so an LSP4J server cannot answer
ServerCancelled for a pull it cancels itself. A pull that LSP4IJ cancels completes at once with a
CancellationException, so a RequestCancelled answer always comes from the server: it now triggers a new pull, as
ServerCancelled does. Other errors still stop the pulls until the next refresh.
@lagergren lagergren added this to the 0.31.0 milestone Nov 19, 2026
@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • Workspace diagnostics now retry automatically when the language server cancels a request, helping keep diagnostic results up to date.
    • Other diagnostic request failures do not trigger an automatic retry; diagnostics are requested again when refreshed.

Workspace diagnostics now retrigger a pull after a RequestCancelled response. Tests cover reuse of a streamed result ID and confirm that an InternalError stops automatic pulls until refresh() is called.

Changes: Workspace diagnostic recovery

Layer / File(s) Summary
Retry cancelled diagnostic pulls
src/main/java/com/redhat/devtools/lsp4ij/features/diagnostics/WorkspaceDiagnosticManager.java, src/test/java/com/redhat/devtools/lsp4ij/features/diagnostics/WorkspaceDiagnosticManagerTest.java
shouldRetrigger now returns true for RequestCancelled. Tests verify that the next pull uses the streamed result ID, and that InternalError requires an explicit refresh() to start another pull.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: Minimal · up to 4ed79

Workspace diagnostic pulls now resume when the server cancels a pull itself, which avoids stale diagnostics. Other errors still stop pulls until the next refresh. The change is small, tested and low risk to merge.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title states the main change: workspace diagnostic pulls resume when the server cancels a pull itself. It matches the shouldRetrigger change in WorkspaceDiagnosticManager and the RequestCancelled …
Description check Passed The description explains the cause (LSP4J maps server-cancelled futures to RequestCancelled), the fix (RequestCancelled now retriggers a pull), the remaining behavior for other errors, and the two add…
Linked Issues check Passed Issue #2027 requires that a server-originated RequestCancelled answer to a workspace diagnostic pull starts another pull, and that other errors keep the pulls stopped until a refresh or registration. …
Out of Scope Changes check Passed The whole-PR change set, as summarized, touches only WorkspaceDiagnosticManager.java (+7/-0, a RequestCancelled retrigger branch and its comment) and WorkspaceDiagnosticManagerTest.java (+27/-0, two t…
Full details: Title check

Explanation

The title states the main change: workspace diagnostic pulls resume when the server cancels a pull itself. It matches the shouldRetrigger change in WorkspaceDiagnosticManager and the RequestCancelled handling described in the objectives.

Full details: Description check

Explanation

The description explains the cause (LSP4J maps server-cancelled futures to RequestCancelled), the fix (RequestCancelled now retriggers a pull), the remaining behavior for other errors, and the two added tests. It links issue #2027. It is related to the changeset.

Full details: Linked Issues check

Explanation

Issue #2027 requires that a server-originated RequestCancelled answer to a workspace diagnostic pull starts another pull, and that other errors keep the pulls stopped until a refresh or registration. The raw summary reports that WorkspaceDiagnosticManager.shouldRetrigger now returns true for RequestCancelled, with a comment that separates server cancellations from client cancellations, which complete with CancellationException. The existing ServerCancelled and other-error paths are unchanged in the summary. The test summary covers both cases: retriesAPullTheServerCancelledItself (next pull uses the previous result IDs) and stopsAfterAFailedPull (InternalError still stops pulls). The reviewed head read of WorkspaceDiagnosticManager.java was truncated before shouldRetrigger, and the whole-PR diff tool was unavailable. The conclusion therefore rests on the raw summary and PR description, not on a direct read of the changed lines. The test run (83 tests, 0 failures) is reported by the author and was not re-run.

Full details: Out of Scope Changes check

Explanation

The whole-PR change set, as summarized, touches only WorkspaceDiagnosticManager.java (+7/-0, a RequestCancelled retrigger branch and its comment) and WorkspaceDiagnosticManagerTest.java (+27/-0, two tests). Both tests cover the issue's requirement. No unrelated files or declaration changes are reported. The diff tool was unavailable, so the file list relies on the raw summary.

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: 7c9f70cb-bbca-4f1c-ba75-064298c307e4
Commits

Reviewing files that changed from the base of the PR and between 329cacb and 4ed797d.

Files selected for processing: 2

  • src/main/java/com/redhat/devtools/lsp4ij/features/diagnostics/WorkspaceDiagnosticManager.java
  • src/test/java/com/redhat/devtools/lsp4ij/features/diagnostics/WorkspaceDiagnosticManagerTest.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 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 49.16%. Comparing base (8655e28) to head (4ed797d).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...atures/diagnostics/WorkspaceDiagnosticManager.java 66.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2029      +/-   ##
==========================================
- Coverage   49.17%   49.16%   -0.02%     
==========================================
  Files         813      813              
  Lines       33095    33098       +3     
  Branches     6771     5129    -1642     
==========================================
- Hits        16276    16271       -5     
- Misses      14275    14278       +3     
- Partials     2544     2549       +5     

☔ 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 lagergren modified the milestones: 0.31.0, 0.30.2 Nov 20, 2026
@lagergren
lagergren merged commit 9e7f1e8 into redhat-developer:main Nov 20, 2026
13 of 14 checks passed
@lagergren lagergren added the bug Something isn't working label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Workspace diagnostics stop when the server cancels a pull itself

1 participant