Skip to content

Clear pull state when a document diagnostic pull fails - #1899

Merged
Dirk Bäumer (dbaeumer) merged 2 commits into
microsoft:mainfrom
trivikr:client-diagnostic-non-cancellation-error
Oct 21, 2026
Merged

Dirk Bäumer (dbaeumer) merged 2 commits into
microsoft:mainfrom
trivikr:client-diagnostic-non-cancellation-error

Conversation

@trivikr

Copy link
Copy Markdown
Contributor

Fixes: #1898

When a document diagnostic pull failed, the client never pulled that document again for the rest of the session.

  • pullAsync now removes the openRequests entry before rethrowing a non-cancellation error. Before, the stale active entry made every later pull look like it was already in flight, so no new request was sent.
  • A server cancellation with retriggerRequest: false now takes the existing outDated path. Before, it fell through to throw error, so it was logged as "Document pull failed" and left the document stuck the same way.

Adds two integration tests. Each makes one pull fail through provideDiagnostics middleware and checks that the next pull still reaches the provider.

pullAsync rethrew non-cancellation errors before removing the request
from openRequests. Later pulls for that document then saw an active
request, so they only marked it for rescheduling and never sent a new
request. The document was never pulled again for the rest of the
session.

A server cancellation with retriggerRequest: false was also rethrown.
The outDated check set afterState, so the check that followed it fell
through to `throw error`. Make the checks an if/else-if chain so that
case takes the existing outDated path instead.
Copilot AI balanced review requested due to automatic review settings October 20, 2026 13:38

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused fixes address both reported failures, with regression coverage and no unresolved findings.

No open issues 🎉

What changed in this PR

Fixes #1898 by allowing document diagnostic pulls to recover after failures instead of remaining blocked for the session.

Changes:

  • Clears stale request state before rethrowing non-cancellation errors.
  • Handles server cancellation without retriggering as an outdated request.
  • Adds regression tests for subsequent pulls and expected error logging.
File Description
client/​src/​common/​diagnostic.ts Fixes failed-request cleanup and cancellation handling.
client-node-tests/​src/​integration.test.ts Tests recovery after errors and server cancellation.

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 21, 2026 05:34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The localized fixes address both reported failures with targeted regression coverage and no identified blocking issues.

No open issues 🎉

Review effort: Balanced

@dbaeumer
Dirk Bäumer (dbaeumer) enabled auto-merge (squash) October 21, 2026 06:29
@dbaeumer
Dirk Bäumer (dbaeumer) merged commit 509f696 into microsoft:main Oct 21, 2026
5 checks passed
@trivikr
Trivikram Kamat (trivikr) deleted the client-diagnostic-non-cancellation-error branch October 21, 2026 06:52
@dbaeumer Dirk Bäumer (dbaeumer) added this to the 3.18.5 milestone Oct 21, 2026
David Wilson (daviwil) added a commit to daviwil/vscode-swift that referenced this pull request Oct 30, 2026
vscode-languageclient 11 includes microsoft/vscode-languageserver-node#1899,
so a failed diagnostic pull no longer stops later pulls for the document.
Remove the middleware that worked around it.

It requires VS Code 1.91, so raise engines.vscode and @types/vscode to
match. Migration changes:

- The package now has an exports map, so the deep imports go. The
  workspace folders feature is recognized by its registration method,
  and the test explorer test imports the protocol converter from the
  $test entry point, which also takes the new supportThemeIcons argument.
- The client's output channel must be a LogOutputChannel, and the client
  only traces the server when the channel's log level is Trace. Wrap the
  SourceKit output channel so it keeps its log file and message format,
  and report Trace while swift.sourcekit-lsp.trace.server isn't off.
Matthew Bastien (matthewbastien) pushed a commit to swiftlang/vscode-swift that referenced this pull request Nov 5, 2026
* Add the PR number to the CHANGELOG entry

* Update vscode-languageclient to 11.0.0

vscode-languageclient 11 includes microsoft/vscode-languageserver-node#1899,
so a failed diagnostic pull no longer stops later pulls for the document.
Remove the middleware that worked around it.

It requires VS Code 1.91, so raise engines.vscode and @types/vscode to
match. Migration changes:

- The package now has an exports map, so the deep imports go. The
  workspace folders feature is recognized by its registration method,
  and the test explorer test imports the protocol converter from the
  $test entry point, which also takes the new supportThemeIcons argument.
- The client's output channel must be a LogOutputChannel, and the client
  only traces the server when the channel's log level is Trace. Wrap the
  SourceKit output channel so it keeps its log file and message format,
  and report Trace while swift.sourcekit-lsp.trace.server isn't off.

* Fix the type and lint errors from the vscode-languageclient update

vscode-languageserver-protocol 3.18's DocumentSelector isn't assignable to
VS Code's, so the document selectors keep their own type, which fits both.
Use the extension's Disposable type, and don't call the deprecated
OutputChannel.show overload. Update package-lock.json.
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.

Document diagnostic pull stops for a document after its pull request fails

5 participants