Skip to content

client: dispose existing registration before re-registering file watcher - #1897

Merged
Dirk Bäumer (dbaeumer) merged 2 commits into
microsoft:mainfrom
reginaldalfret:fix/reginald-lsp-watcher-duplicate-id-leak
Oct 21, 2026
Merged

Dirk Bäumer (dbaeumer) merged 2 commits into
microsoft:mainfrom
reginaldalfret:fix/reginald-lsp-watcher-duplicate-id-leak

Conversation

@reginaldalfret

Copy link
Copy Markdown
Contributor

Resolves #1879

Description

When dynamic file watcher registrations (
egister() or
egisterRaw()) are invoked with an ID that has already been registered, previously the old Disposable instances remained in memory while being overwritten in _watchers.

Changes

Call his.unregister(data.id) in
egister() and his.unregister(id) in
egisterRaw() before setting up the new disposables. This ensures that any existing watchers and event listeners under that ID are cleanly disposed without leaking.

Copilot AI balanced review requested due to automatic review settings October 19, 2026 18:58

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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

Both registration paths reuse existing cleanup logic, with no unresolved findings.

No open issues 🎉

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 21, 2026 08:06

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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

Both focused changes reuse existing cleanup logic, with no unresolved findings.

No open issues 🎉

Review effort: Balanced

@dbaeumer
Dirk Bäumer (dbaeumer) merged commit 6687d48 into microsoft:main Oct 21, 2026
5 checks passed
@dbaeumer Dirk Bäumer (dbaeumer) added this to the 3.18.5 milestone Oct 21, 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.

Re-registering file watchers with the same ID will leak the previous registration

5 participants