Skip to content

fix: prevent listener leak from duplicate status IDs in language status (#309042)#309159

Merged
jrieken merged 2 commits intomicrosoft:mainfrom
maruthang:fix/issue-309042-listener-leak-language-status
Apr 17, 2026
Merged

fix: prevent listener leak from duplicate status IDs in language status (#309042)#309159
jrieken merged 2 commits intomicrosoft:mainfrom
maruthang:fix/issue-309042-listener-leak-language-status

Conversation

@maruthang
Copy link
Copy Markdown
Contributor

Summary

Fixes #309042

Bug: A listener leak was detected in languageStatus.ts at line 280, triggered when duplicate status IDs appeared momentarily during status updates.

Root Cause: In the _update() method's dedicated entries loop, when the same status ID appeared twice during an update cycle, the code only checked this._dedicatedEntries (from the previous update) and not the entries already created in the current update. This caused a new addEntry call for a duplicate ID, leaking the previous accessor's disposable.

Fix: Added a check against newDedicatedEntries (entries already processed in the current update) before falling back to this._dedicatedEntries, preventing duplicate entry accessor creation.

Changes

  • src/vs/workbench/contrib/languageStatus/browser/languageStatus.ts: In the dedicated entries loop of _update(), check newDedicatedEntries first (via ??) before this._dedicatedEntries to catch duplicate status IDs within the same update cycle.
  • src/vs/workbench/contrib/languageStatus/test/common/languageStatusDedupe.test.ts: Added 7 regression tests covering duplicate ID scenarios, verifying that existing accessors are reused and no extra entries are created.

Testing

  • Added regression test suite in src/vs/workbench/contrib/languageStatus/test/common/languageStatusDedupe.test.ts that verifies:
    • Duplicate status IDs reuse existing accessors instead of creating new ones
    • The newDedicatedEntries map correctly prevents duplicate addEntry calls
    • Entry updates work correctly when an accessor already exists
    • Edge cases with multiple duplicates and mixed new/existing entries
  • All existing tests pass

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

Fixes a listener leak in the workbench Language Status UI by preventing duplicate status IDs (within a single update pass) from creating multiple status bar entry accessors, which could orphan the earlier accessor and leak listeners.

Changes:

  • Reuse an accessor already created earlier in the same _update() cycle by checking newDedicatedEntries before falling back to this._dedicatedEntries.
  • Add a dedicated regression test suite covering duplicate-ID scenarios and mixed reuse/create/dispose behavior.
Show a summary per file
File Description
src/vs/workbench/contrib/languageStatus/browser/languageStatus.ts Prevents duplicate addEntry calls for the same status ID within a single update cycle by reusing the in-flight accessor.
src/vs/workbench/contrib/languageStatus/test/common/languageStatusDedupe.test.ts Adds regression coverage for duplicate dedicated status IDs to ensure accessor reuse and correct disposal behavior.

Copilot's findings

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

@jrieken jrieken enabled auto-merge April 17, 2026 10:42
@jrieken jrieken merged commit 34567bc into microsoft:main Apr 17, 2026
26 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.117.0 milestone Apr 17, 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.

[Unhandled Error] potential listener LEAK detected, dominated

5 participants