Repository navigation
fix: memory leak in integrated browser element handles - #338247
Merged
Dmitriy Vasyura (dmitrivMS) merged 1 commit intoSep 28, 2026
Merged
Dmitriy Vasyura (dmitrivMS) merged 1 commit into
Dmitriy Vasyura (dmitrivMS) merged 1 commit into
Conversation
Contributor
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: Kyle Cutler (@kycutler)Matched files:
Joaquín Ruales (@jruales)Matched files:
|
Copilot started reviewing on behalf of
Simon Siefke (SimonSiefke)
September 27, 2026 19:13
View session
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The cleanup is correctly scoped and comprehensively tested without changing extraction results or errors.
Review effort: Balanced
Findings: None
What changed in this PR
Fixes a remote object handle leak during integrated-browser element extraction.
Changes:
- Releases temporary CDP handles in a failure-safe
finallyblock. - Adds tests for success, failure, asynchronous extraction, and cleanup errors.
| File | Description |
|---|---|
browserViewFrameInspector.ts |
Releases temporary element handles after extraction. |
browserViewFrameInspector.test.ts |
Verifies handle lifecycle and error preservation. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Dmitriy Vasyura (dmitrivMS)
approved these changes
Sep 28, 2026
Dmitriy Vasyura (dmitrivMS)
enabled auto-merge (squash)
September 28, 2026 06:42
Collaborator
|
Simon Siefke (@SimonSiefke) Thank you! |
Christof Marti (chrmarti)
approved these changes
Sep 28, 2026
Ladislau Szomoru (lszomoru)
approved these changes
Sep 28, 2026
Dmitriy Vasyura (dmitrivMS)
merged commit Sep 28, 2026
f5e3fca
into
microsoft:main
55 of 56 checks passed
Simon Siefke (SimonSiefke)
deleted the
fix/memory-leak-browserElement-remoteHandles
branch
September 29, 2026 11:15
Abdon Morales (abdonmorales)
pushed a commit
to abdonmorales/vscode-utcs
that referenced
this pull request
Oct 1, 2026
) Fix temporary browser element remote handle disposal (cherry picked from commit f5e3fca)
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
Adding a browser element to chat creates a temporary remote object handle while extracting its details. That handle is never released, so removing the attachment and DOM element leaves the old element state in the browser process.
Change
Release the temporary handle after extraction finishes, including when extraction fails. Preserve the original result or error if the frame disappears during cleanup.
Before
Adding an element to chat, removing the attachment, and removing the DOM element 37 times adds 37 old selected-element state objects.
After
No more selected-element state growth is detected in the same 37-cycle test. Separate WeakRef wrapper growth disappears after garbage collection; unrelated native and string growth remains in the broader diagnostic.
Test Video
Seven element selection, attachment removal, and DOM removal cycles in the integrated browser.
test.mp4
AI disclosure: Model: GPT 6 Astra. Worktime: 53 min