Skip to content

Fix listener leak in FocusSessionActionViewItem#311758

Closed
roblourens wants to merge 3 commits intomainfrom
roblou/agents/vscode-issue-308534-fix
Closed

Fix listener leak in FocusSessionActionViewItem#311758
roblourens wants to merge 3 commits intomainfrom
roblou/agents/vscode-issue-308534-fix

Conversation

@roblourens
Copy link
Copy Markdown
Member

Fixes #308534 (Written by Copilot)

Listeners added to debug sessions (onDidChangeName / onDidEndAdapter) in FocusSessionActionViewItem's constructor were not tied to the view item's lifetime. Since debug sessions outlive the action view item (it gets recreated on toolbar / title-area updates), each recreation piled more listeners onto the same long-lived sessions, eventually tripping the "potential listener LEAK detected, popular" warning from the REPL title toolbar.

Fix: route all per-session listeners through a DisposableStore owned by the view item, so they're released when the view item is disposed — while still self-cleaning when the session ends (and removing themselves from the parent store so disposed children don't accumulate).

(Recreated from #311745, which was closed because some CI jobs got stuck.)

roblourens and others added 3 commits April 21, 2026 10:23
Listeners added to debug sessions (onDidChangeName/onDidEndAdapter) in
the constructor were not tied to the view item's lifetime. Since debug
sessions outlive the action view item (recreated on toolbar updates),
each recreation piled more listeners onto the same sessions, eventually
triggering the 'potential listener LEAK detected' warning.

Route all per-session listeners through a DisposableStore owned by the
view item so they are released when the view item is disposed, while
still self-cleaning when the session ends.

Fixes #308534

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use sessionListenersStore.delete() instead of sessionListeners.dispose()
so that ended sessions don't accumulate disposed stores in the parent.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 21, 2026 18:43
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a listener leak in FocusSessionActionViewItem (Debug / REPL toolbar session selector) by ensuring per-debug-session listeners are disposed with the view item’s lifetime, preventing listener accumulation across action view item re-creations.

Changes:

  • Introduces a DisposableStore owned by FocusSessionActionViewItem to own all per-session listeners.
  • Registers per-session onDidChangeName / onDidEndAdapter listeners via per-session child stores.
  • Removes per-session listener stores from the parent store when sessions end to avoid growth over time.
Show a summary per file
File Description
src/vs/workbench/contrib/debug/browser/debugActionViewItems.ts Routes session listeners through a view-item-owned DisposableStore and cleans up per-session stores on adapter end to prevent listener leaks.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 0

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.

[Unhandled Error] potential listener LEAK detected, popular — debug/repl / debugActionViewItems

2 participants