Avoid terminal link provider listeners for detached terminals - #332470
Merged
Dmitriy Vasyura (dmitrivMS) merged 4 commits intoAug 26, 2026
Merged
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Dmitriy Vasyura (dmitrivMS)
enabled auto-merge (squash)
August 25, 2026 01:59
Copilot started reviewing on behalf of
Dmitriy Vasyura (dmitrivMS)
August 25, 2026 02:02
View session
Contributor
There was a problem hiding this comment.
Pull request overview
Prevents detached terminals from retaining unused external link-provider listeners.
Changes:
- Guards provider-removal subscriptions for detached terminals.
- Adds regression coverage for detached and regular terminals.
Show a summary per file
| File | Description |
|---|---|
terminal.links.contribution.ts |
Moves removal listener into the regular-terminal guard. |
terminalLinkContribution.test.ts |
Tests listener registration and disposal behavior. |
Review details
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Balanced
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
| linkManager.externalProvideLinksCb = e.provideLinks.bind(e, this._ctx.instance as ITerminalInstance); | ||
| })); | ||
| } | ||
| linkManager.add(this._terminalLinkProviderService.onDidRemoveLinkProvider(() => linkManager.externalProvideLinksCb = undefined)); |
Collaborator
Author
There was a problem hiding this comment.
The code moved to another file for testing purposes, but the only change is this line is now included in the if above
|
الجامد بزيادة |
|
تم |
Anthony Kim (anthonykim1)
approved these changes
Aug 25, 2026
Anthony Kim (anthonykim1)
left a comment
Contributor
There was a problem hiding this comment.
Thanks! I dont think we register extension provided link provider for detached terminal so this should be good for now.
Dmitriy Vasyura (dmitrivMS)
deleted the
dev/dmitriv/detached-terminal-link-listener-leak
branch
August 26, 2026 06:29
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Root cause
TerminalLinkContribution.xtermReady()already skips external provider setup for detached terminals, but theonDidRemoveLinkProvidersubscription was outside that guard. Every detached terminal created for chat output therefore added a no-op listener to the singletonTerminalLinkProviderServiceemitter. Tool-heavy agent sessions eventually crossed the listener leak threshold.The provider-removal listener now lives beside the provider-add listener inside the existing non-detached guard.
Validation
npm run transpile-clientgit diff --checkRelated issues
Fixes #308254
Related to #311225
Related to #294050
The related crash reports contain this detached-terminal listener signature among several independent memory-retention paths, so they are intentionally non-closing references.