Repository navigation
fix: memory leak in debouncedObservable - #346498
Merged
Dmitriy Vasyura (dmitrivMS) merged 4 commits intoNov 7, 2026
Merged
Dmitriy Vasyura (dmitrivMS) merged 4 commits into
Dmitriy Vasyura (dmitrivMS) merged 4 commits into
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
A fake-timer regression test is still needed to verify that removing the last observer cancels pending debounce delivery and prevents stale values after resubscription.
1 open issue
What changed in this PR
This PR fixes pending debounce timer cleanup in VS Code’s shared observable utilities, addressing retained state after a peek editor’s inline chat observers are removed.
Changes:
- Cancel the pending debounce timer when the last observer is removed.
- Reset the timer handle alongside the existing cached-value cleanup.
| File | Description |
|---|---|
src/vs/base/common/observableInternal/utils/utils.ts |
Clear and reset the pending timer during debouncedObservable disposal. |
Review effort: Balanced
Collaborator
|
Simon Siefke (@SimonSiefke) Thank you! |
Dmitriy Vasyura (dmitrivMS)
enabled auto-merge (squash)
November 6, 2026 23:47
Dmitriy Vasyura (dmitrivMS)
approved these changes
Nov 6, 2026
Ben Villalobos (benvillalobos)
approved these changes
Nov 6, 2026
Vijay Upadya (vijayupadya)
approved these changes
Nov 7, 2026
Simon Siefke (SimonSiefke)
deleted the
fix/memory-leak-debouncedObservable
branch
November 11, 2026 10:35
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.

Details
When a peek editor closes, its inline chat affordance removes its observers from the debounced selection. The pending debounce timer is not cancelled.
Change
Cancel the pending debounce timer and reset its handle when the last observer is removed.
Before
When opening and closing a TypeScript peek definition 37 times,
InteractionEmittergrows from 22 to 64:After
No more leak detected.
Test Video
typescript-peek-definition.webm
AI disclosure: Model: GPT-6.1 Sol. Worktime: 26 min