Repository navigation
webview: fix resource loading cancellation listener leaks - #338306
Merged
Dmitriy Vasyura (dmitrivMS) merged 1 commit intoSep 28, 2026
Merged
Conversation
Scope cancellation to each resource request and release its lifetime when streaming completes, fails, or is cancelled. Cancel the underlying file read without destroying stream cleanup, and dispose linked cancellation sources when read setup throws. Add regression coverage for parallel loads, cancellation, disposal, shared buffer views, and handle closure after read failures. Fixes #319468 Co-authored-by: Copilot <[email protected]>
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The lifecycle changes are internally consistent and covered across the relevant success, failure, cancellation, and disposal paths.
Review effort: Balanced
Findings: None
What changed in this PR
Fixes webview resource-loading cancellation listener leaks by scoping cancellation and cleanup per request.
Changes:
- Tracks each webview resource stream through completion, cancellation, failure, or disposal.
- Cleans up file-service cancellation sources on synchronous setup failures.
- Adds regression tests for concurrency, cancellation, errors, buffer views, and handle closure.
| File | Description |
|---|---|
webviewElement.ts |
Adds request-scoped stream lifecycle management. |
webviewElement.test.ts |
Covers resource-stream cleanup and concurrency. |
fileService.ts |
Disposes cancellation state on setup failure. |
fileService.test.ts |
Covers listener and file-handle cleanup. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Dmitriy Vasyura (dmitrivMS)
marked this pull request as ready for review
September 28, 2026 08:28
Dmitriy Vasyura (dmitrivMS)
enabled auto-merge (squash)
September 28, 2026 08:28
Ladislau Szomoru (lszomoru)
approved these changes
Sep 28, 2026
Christof Marti (chrmarti)
approved these changes
Sep 28, 2026
Dmitriy Vasyura (dmitrivMS)
deleted the
agents/fix-unhandled-error-listener-leak
branch
September 28, 2026 08:39
Abdon Morales (abdonmorales)
pushed a commit
to abdonmorales/vscode-utcs
that referenced
this pull request
Oct 1, 2026
…338306) Scope cancellation to each resource request and release its lifetime when streaming completes, fails, or is cancelled. Cancel the underlying file read without destroying stream cleanup, and dispose linked cancellation sources when read setup throws. Add regression coverage for parallel loads, cancellation, disposal, shared buffer views, and handle closure after read failures. Fixes microsoft#319468 Co-authored-by: Copilot <[email protected]> (cherry picked from commit 2f1fe6e)
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Fixes #319468
Summary
Reproduction
Before the fix, 200 parallel resource loads reproduced the exact
potential listener LEAK detected, popularwarning and call stack from the issue. Five synchronous read failures retained 1, 2, 3, 4, and 5 listeners; cancelling a transferred response left its file read running. These cases now pass, and three batches of 200 reads return to zero active requests after each batch.The parallel-load warning is caused by shared-token fan-out; the failed/aborted-read cases also exposed actual cleanup problems. This does not claim to resolve the separate high-CPU/freeze symptoms reported in the issue comments.
Validation
npm run gulp compile-client: passed, zero errors.git diff --check: passed.Historical regression coverage includes #326272/#326092 (resource concurrency), #321291/#316841 (shared-buffer detachment), #114428/#114024 (handle closure on cancellation/errors), #138805/#132771 (binary-read cancellation), #337018 (pending stream writes), and #312367 (listener/controller cleanup).
Native validation was on Windows; Linux's FD ceiling and the reported macOS CPU spin were not directly exercised. The partially built development worktree logged unrelated missing built-in extension outputs during full-window tests; the webview tests passed, with no listener-leak, EMFILE, or unresponsive-renderer reports in their logs.