Skip to content

debug: dispose inline adapter message subscriptions - #338371

Merged
Dmitriy Vasyura (dmitrivMS) merged 3 commits into
mainfrom
agents/fix-issue-293200-ext-host-debug-1257
Sep 28, 2026
Merged

Dmitriy Vasyura (dmitrivMS) merged 3 commits into
mainfrom
agents/fix-issue-293200-ext-host-debug-1257

Conversation

@dmitrivMS

Copy link
Copy Markdown
Collaborator

Refs #293200, only the unchecked extHostDebugService.ts:1257 direct subscription item (Matt Bierner (@mjbvz); task key ext-host-debug-1257).

Problem

The original subscription is DirectDebugAdapter's listener on implementation.onDidSendMessage (line 1257 at issue-date revision 3ef1567cc09dff5500ff510a85182a1b65da53a6, line 1273 on the baseline).

Stopping a session disposes the implementation, but that does not unsubscribe the wrapper when the event publisher belongs to a longer-lived extension service. The publisher can retain the wrapper and its debug-service callback after the session ends. Session-owned publishers that release their listeners do not exhibit this leak.

Change

  • Keep the subscription disposable on the inline wrapper and release it on wrapper disposal.
  • Dispose the wrapper before disposing the implementation when stopping, including when implementation disposal throws.
  • Add regression coverage for stopping, direct disposal, surviving adapters/communication, and implementation disposal errors.

Validation

  • npm run compile-client: passed, including TypeScript compilation.
  • Targeted ESLint: passed for both changed files.
  • Four new regression tests fail on unchanged baseline; all four pass with the fix. Together with adjacent debug visualization tests: 11 passing (including the runner's clean-state check).
  • Actual Code OSS, Windows local extension host, isolated empty profiles and a synthetic inline adapter:
  • Two independent, read-only whole-change reviews: gpt-6-astra and claude-opus-5.5, each with default reasoning effort; no actionable findings.

Scope and limits

Open leak PRs #334102 and #334103 address different main-thread registrations and do not fix this subscription. No umbrella checklist changes are included.

This verifies the Windows/local synthetic inline-adapter cases above, not remote/browser extension hosts, other operating systems, arbitrary third-party adapters, or general heap-size/performance claims. Historical repro mechanisms were exercised in the synthetic product harness, not the original macOS macro extension or a nested development debugger.

Refs #293200 (ext-host-debug-1257 only).

Co-authored-by: Copilot <[email protected]>
Copilot AI balanced review requested due to automatic review settings September 28, 2026 12:26
@dmitrivMS Dmitriy Vasyura (dmitrivMS) added the freeze-slow-crash-leak VS Code crashing, performance, freeze and memory leak issues label Sep 28, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The lifecycle fix is narrowly scoped, preserves teardown behavior, and has comprehensive regression coverage.

Review effort: Balanced
Findings: None

What changed in this PR

Fixes an extension-host leak by releasing inline debug adapter message subscriptions when adapters stop or are disposed.

Changes:

  • Tracks and disposes onDidSendMessage subscriptions before implementation teardown.
  • Adds regression coverage for disposal, shared publishers, surviving adapters, and teardown errors.
File Description
src/​vs/​workbench/​api/​common/​extHostDebugService.ts Disposes the inline adapter subscription during teardown.
src/​vs/​workbench/​api/​test/​browser/​extHostDebugAdapters.test.ts Adds focused lifecycle and leak regression tests.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@dmitrivMS Dmitriy Vasyura (dmitrivMS) added the debug Debug viewlet, configurations, breakpoints, adapter issues label Sep 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Screenshot Changes

Base: 12dc71b3 Current: 66dac9d5

Changed (1)

sessions/sessionsList/SessionsList_NestedChatApprovals_Phone/Dark
Before After
before after

8 insignificant change(s) omitted (≤20 px, Δ≤2). See CI logs for details.

@dmitrivMS
Dmitriy Vasyura (dmitrivMS) marked this pull request as ready for review September 28, 2026 16:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

debug Debug viewlet, configurations, breakpoints, adapter issues freeze-slow-crash-leak VS Code crashing, performance, freeze and memory leak issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants