You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Error] [GitHub.copilot-chat] unhandlederror-Response stream has been closed #316444
at <REDACTED: user-file-path> VS <REDACTED: (../src/extension/chatSessions/common/externalEditTracker.ts:66:32)
at wse.trackEdit (../src/extension/chatSessions/common/externalEditTracker.ts:54:9)
at NQt (../src/extension/chatSessions/copilotcli/node/permissionHelpers.ts:344:21)
at trackEditIfNeeded (../src/extension/chatSessions/copilotcli/node/permissionHelpers.ts:175:9)
at async <REDACTED: user-file-path> VS <REDACTED: (../src/extension/chatSessions/copilotcli/node/copilotcliSession.ts:1186:17)
Raw Stack Trace (minified)
Error: Response stream has been closed at <REDACTED: user-file-path> VS <REDACTED: user-file-path>/resources\app\extensions\copilot\dist\extension.js:2470:12357 at new Promise (<anonymous>) at wse.trackEdit (<REDACTED: user-file-path> VS <REDACTED: user-file-path>/resources\app\extensions\copilot\dist\extension.js:2470:12236) at NQt (<REDACTED: user-file-path> VS <REDACTED: user-file-path>/resources\app\extensions\copilot\dist\extension.js:2538:809) at sHn (<REDACTED: user-file-path> VS <REDACTED: user-file-path>/resources\app\extensions\copilot\dist\extension.js:2533:11317) at async <REDACTED: user-file-path> VS <REDACTED: user-file-path>/resources\app\extensions\copilot\dist\extension.js:2544:4532
Note: An existing issue #312810 tracks the same error message from extension v0.45.1, but with a completely different code path (stream push/progress). This spiked bucket in v0.48.0 originates from the externalEditTracker / permissionHelpers code path — a distinct occurrence.
Stable release anomaly scan: GitHub.copilot-chat 0.48.0 vs 0.47.1
Error: unhandlederror-Response stream has been closed in GitHub.copilot-chat extension v0.48.0 (3x spike vs v0.47.1).
When the chat response stream is closed (e.g., user cancels or session ends) while handleWritePermission is resolving permission checks, the subsequent call to trackEditIfNeeded → trackEdit → stream.externalEdit() throws "Response stream has been closed" because the stream is already invalid. The trackEditIfNeeded function was not forwarding the token parameter to editTracker.trackEdit(), so trackEdit's built-in cancellation guard at externalEditTracker.ts:50 (if token?.isCancellationRequested return) never fired.
Culprit Commit
3b2b5e06 by @DonJayamanne — "Update GitHub Copilot npm and permission handling (#313364)" (2026-04-30). This commit updated permission handling and introduced trackEditIfNeeded call sites that don't forward the cancellation token.
Code Flow
graph TD
A["copilotcliSession.ts:1186 - permission.requested handler"] --> B["handleWritePermission - permissionHelpers.ts:112"]
B --> C["trackEditIfNeeded - permissionHelpers.ts:341"]
C --> D["editTracker.trackEdit(id, uris, stream) — NO token passed"]
D --> E["trackEdit checks token?.isCancellationRequested → undefined, skips guard"]
E --> F["stream.externalEdit() → throws 'Response stream has been closed'"]
Crash site — stream.externalEdit() throws when stream is closed
Repro Steps
Start a Copilot CLI session in VS Code
Trigger a file edit that goes through permission handling
Cancel the session or close the chat response while the permission check is still resolving
The trackEditIfNeeded call proceeds after the stream is closed, calling stream.externalEdit() which throws
Fix Proposal
Bypass identified: Missing token forwarding at permissionHelpers.ts:341-344 — trackEditIfNeeded does not pass the token parameter to editTracker.trackEdit().
Why it fails: trackEdit in externalEditTracker.ts accepts an optional token parameter and guards against cancelled tokens at line 50, but since trackEditIfNeeded never passes a token, this guard is dead code. When the stream is closed due to cancellation, stream.externalEdit() at line 66 throws.
Fix location: permissionHelpers.ts → trackEditIfNeeded() and its 3 call sites in handleWritePermission()
Approach:
Add token?: CancellationToken parameter to trackEditIfNeeded
Forward token to editTracker.trackEdit() call
Pass token from all 3 call sites in handleWritePermission (lines 151, 175, 181)
Note: PR creation failed due to the vscode checkout being in a subdirectory. The fix has been committed locally on branch fix/copilot-stream-closed-316444 in the vscode-repo checkout.
Recommended Owner
@DonJayamanne — author of the permission handling code and all recent commits to permissionHelpers.ts.
Regression type: new (bucket-ID drift — same logical error continuing)
An automated extension regression scan (GitHub.copilot-chat v0.69.0 vs previous stable minor v0.68.0) shows the Response stream has been closed error continuing on v0.69.0 under new bucket IDs (bucket IDs drift across builds as minification changes).
The signature spans 10 buckets on v0.69.0, affecting ~297 users total. These buckets have been linked to this issue:
Activity
vs-code-engineering commentedon May 14, 2026
Stable Release Anomaly Details
spikeDeminified Stack
externalEditTracker.ts:66externalEditTracker.ts:54trackEditpermissionHelpers.ts:344permissionHelpers.ts:175trackEditIfNeededcopilotcliSession.ts:1186Note: An existing issue #312810 tracks the same error message from extension v0.45.1, but with a completely different code path (stream push/progress). This spiked bucket in v0.48.0 originates from the
externalEditTracker/permissionHelperscode path — a distinct occurrence.Stable release anomaly scan: GitHub.copilot-chat 0.48.0 vs 0.47.1
vs-code-engineering commentedon May 14, 2026
🔧 Error Fix Analysis
Summary
Error:
unhandlederror-Response stream has been closedinGitHub.copilot-chatextension v0.48.0 (3x spike vs v0.47.1).When the chat response stream is closed (e.g., user cancels or session ends) while
handleWritePermissionis resolving permission checks, the subsequent call totrackEditIfNeeded→trackEdit→stream.externalEdit()throws "Response stream has been closed" because the stream is already invalid. ThetrackEditIfNeededfunction was not forwarding thetokenparameter toeditTracker.trackEdit(), sotrackEdit's built-in cancellation guard atexternalEditTracker.ts:50(if token?.isCancellationRequested return) never fired.Culprit Commit
3b2b5e06by@DonJayamanne— "Update GitHub Copilot npm and permission handling (#313364)" (2026-04-30). This commit updated permission handling and introducedtrackEditIfNeededcall sites that don't forward the cancellation token.Code Flow
graph TD A["copilotcliSession.ts:1186 - permission.requested handler"] --> B["handleWritePermission - permissionHelpers.ts:112"] B --> C["trackEditIfNeeded - permissionHelpers.ts:341"] C --> D["editTracker.trackEdit(id, uris, stream) — NO token passed"] D --> E["trackEdit checks token?.isCancellationRequested → undefined, skips guard"] E --> F["stream.externalEdit() → throws 'Response stream has been closed'"]Affected Files
extensions/copilot/src/extension/chatSessions/copilotcli/node/permissionHelpers.tstrackEditIfNeededomitstokenparamextensions/copilot/src/extension/chatSessions/common/externalEditTracker.tsstream.externalEdit()throws when stream is closedRepro Steps
trackEditIfNeededcall proceeds after the stream is closed, callingstream.externalEdit()which throwsFix Proposal
Bypass identified: Missing token forwarding at
permissionHelpers.ts:341-344—trackEditIfNeededdoes not pass thetokenparameter toeditTracker.trackEdit().Why it fails:
trackEditinexternalEditTracker.tsaccepts an optionaltokenparameter and guards against cancelled tokens at line 50, but sincetrackEditIfNeedednever passes a token, this guard is dead code. When the stream is closed due to cancellation,stream.externalEdit()at line 66 throws.Fix location:
permissionHelpers.ts→trackEditIfNeeded()and its 3 call sites inhandleWritePermission()Approach:
token?: CancellationTokenparameter totrackEditIfNeededtokentoeditTracker.trackEdit()calltokenfrom all 3 call sites inhandleWritePermission(lines 151, 175, 181)And at each call site:
Note: PR creation failed due to the vscode checkout being in a subdirectory. The fix has been committed locally on branch
fix/copilot-stream-closed-316444in thevscode-repocheckout.Recommended Owner
@DonJayamanne— author of the permission handling code and all recent commits topermissionHelpers.ts.vs-code-engineering commentedon Oct 9, 2026
Regression Details
GitHub.copilot-chat)new(bucket-ID drift — same logical error continuing)An automated extension regression scan (GitHub.copilot-chat v0.69.0 vs previous stable minor v0.68.0) shows the
Response stream has been closederror continuing on v0.69.0 under new bucket IDs (bucket IDs drift across builds as minification changes).The signature spans 10 buckets on v0.69.0, affecting ~297 users total. These buckets have been linked to this issue:
af0d0abad1b27967733678506e77f0cc0e676107efcb18d49997786f61b38c734f5d146290c6e70dCommit-range narrowing is skipped for extension-mode scans.