Skip to content

Dispose workspace diagnostic progress handler on all paths - #1905

Merged
Dirk Bäumer (dbaeumer) merged 1 commit into
microsoft:mainfrom
trivikr:client-diagnostic-on-progress-handler
Oct 22, 2026
Merged

Dirk Bäumer (dbaeumer) merged 1 commit into
microsoft:mainfrom
trivikr:client-diagnostic-on-progress-handler

Conversation

@trivikr

Copy link
Copy Markdown
Contributor

provideWorkspaceDiagnostics leaked its partial result progress handler on three paths:

  • Client disposed or not running: the handler was registered before the isDisposed / isRunning() check, so the early return left it in place.
  • Cancelled: the token.isCancellationRequested early return skipped disposable.dispose().
  • convertReport throws: the throw happens in the fulfillment callback, which the sibling rejection callback doesn't catch, so neither dispose() ran.

Workspace pulls repeat every 2 seconds, so leaked handlers accumulate in the client's progress handler map.

provideWorkspaceDiagnostics registered a partial result progress
handler before checking whether the client was running. It also
skipped disposing that handler when the request was cancelled or when
converting the report threw. Workspace pulls repeat every 2 seconds,
so the leaked handlers accumulated.

Check isDisposed/isRunning before registering the handler, and dispose
it in a single finally after the request settles.
Copilot AI balanced review requested due to automatic review settings October 21, 2026 21:21

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 cleanup change addresses the reported leaks, includes targeted regression tests, and has no identified blocking issues.

No open issues 🎉

What changed in this PR

Fixes workspace diagnostic progress-handler leaks in the language client, preventing handlers from accumulating across repeated pulls.

Changes:

  • Checks client state before registering a progress handler.
  • Uses finally to dispose the handler after success, cancellation, request failure, or report-conversion failure.
  • Adds regression tests for stopped clients, cancellation, and conversion errors.
File Description
client/​src/​common/​diagnostic.ts Moves the client-state guard and centralizes progress-handler cleanup.
client-node-tests/​src/​integration.test.ts Adds handler-tracking support and regression tests for the reported leak paths.

Review effort: Balanced

@dbaeumer
Dirk Bäumer (dbaeumer) merged commit f4eb359 into microsoft:main Oct 22, 2026
5 checks passed
@dbaeumer Dirk Bäumer (dbaeumer) added this to the 3.18.6 milestone Oct 22, 2026
@trivikr
Trivikram Kamat (trivikr) deleted the client-diagnostic-on-progress-handler branch October 26, 2026 19:09
@dbaeumer Dirk Bäumer (dbaeumer) added this to the 3.18.6 milestone Nov 19, 2026
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.

5 participants