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 #322760
at _2 (../src/extension/intents/node/hookResultProcessor.ts:132:16)
at processHookResults (../src/extension/chat/vscode-node/chatHookService.ts:513:2)
at process.processTicksAndRejections (node:<REDACTED: user-file-path>:104:5) [not deminified]
at async PQi (../src/extension/prompts/node/panel/toolCalling.tsx:621:24)
Raw Stack Trace (minified)
Error: Response stream has been closed at _2 (c:\Program <REDACTED: user-file-path> VS <REDACTED: user-file-path>/resources\app\extensions\copilot\dist\extension.js:1749:6) at Qye.executePostToolUseHook (c:\Program <REDACTED: user-file-path> VS <REDACTED: user-file-path>/resources\app\extensions\copilot\dist\extension.js:6826:706) at process.processTicksAndRejections (node:<REDACTED: user-file-path>:104:5) at async PQi (c:\Program <REDACTED: user-file-path> VS <REDACTED: user-file-path>/resources\app\extensions\copilot\dist\extension.js:1693:106)
No fix proposed — already fixed in main by #321959 (commit 3d575eec); the shipped 0.53.1 bundle predates that fix. Its bundle lacks the exact 10-line cancellation re-check guard that PR added — confirmed by the deminified call-site offset (chatHookService.ts:513 in 0.53.1 vs :523 in fixed source, a 10-line delta that matches PR #321959's +10 diff).
Summary
The agent-mode PostToolUse hook path throws an unhandled Response stream has been closed. When a chat request is cancelled while a PostToolUse hook is still running (it spawns external, user-configured commands and can take arbitrarily long), the response stream is already closed by the time the hook resolves; processHookResults then writes hook progress/warnings to the now-closed stream, and core's extHostChatAgents2.ts throws. This is a recurrence of the already-fixed #321951 / #319003 on a pre-fix build — extension 0.53.1 (win32, 54 users) does not contain the re-check guard merged to main on 2026-06-19, so no new code change is warranted.
Culprit Commit
This bucket is not a new regression — it is a pre-fix build of a bug already fixed in main. There is no new culprit commit; the reference fix is:
The deminified call site chatHookService.ts:513 in 0.53.1 is exactly 10 lines above the same processHookResults call in fixed source (:523); that 10-line delta equals PR #321959's +10 guard block, so 0.53.1 was built without the guard.
The underlying race long predates these trackers (it has existed since hook execution moved into the extension); cdf17eb2 (#319011) added a pre-hook cancellation guard, and 3d575eec (#321959) closed the remaining during-hook window.
Code Flow
sequenceDiagram
participant TC as toolCalling.tsx
participant CHS as chatHookService.ts
participant HRP as hookResultProcessor.ts
participant Core as extHostChatAgents2.ts
TC->>TC: appendHookContext() pre-hook guard isCancellationRequested? (false)
TC->>CHS: executePostToolUseHook(stream, token)
CHS->>CHS: await executeHook('PostToolUse') spawns external command (slow)
Note over Core: user cancels; finally runs stream.close() sets _isClosed = true
Note over CHS: 0.53.1 lacks the post-await re-check guard
CHS->>HRP: processHookResults({ outputStream })
HRP->>Core: outputStream.hookProgress(warning)
Core-->>HRP: throwIfDone() throws "Response stream has been closed"
Why no fix proposal: the error is already fixed in main by #321959 (3d575eec); this bucket is a pre-fix 0.53.1 build, so there is no source change to make — per the errors-triage "Expected (pre-fix build)" rule, the fix simply needs to reach the 0.53.x stable line.
Hypotheses to test (only relevant if the bucket persists on a build that does contain #321959):
Residual non-cancellation close window — stream.close() at extHostChatAgents2.ts:1070 also runs in the finally when the agent task throws or times out, not only on cancellation. If a PostToolUse hook is still in flight at that moment and the token is not cancelled, the token-based re-check guard would not catch it. Disprove by confirming the tool-calling loop always awaits every in-flight hook before the task settles for non-cancellation reasons.
Cherry-pick gap — disprove by checking whether 3d575eec was ported to the release/0.53 branch before 0.53.1 was cut; if not, every 0.53.1 user keeps hitting this until they move to a build that includes the fix.
Instrumentation to add (so a true post-fix recurrence is distinguishable): the bucket ### Details already records the resolved extension version, which is sufficient to separate pre-fix 0.53.1 hits from any future post-fix hit. If it does recur at or above the fixed version, enrich the throw at extHostChatAgents2.tsthrowIfDone() with the close reason (cancelled vs completed vs errored) so residual-gap occurrences can be told apart from pre-fix builds without source archaeology.
Question for the area owner: was 3d575eec (#321959) cherry-picked into the release/0.53 stable branch, or will 0.53.x users only receive the fix when they upgrade to the next minor?
Recommended Owner
@pwang347 — owns Chat Hooks per triage/working-areas.md, authored/owned both prior fixes for this exact path (#319011, #321959), and is an active contributor (committed to chatHookService.ts on 2026-06-09, PR #320520). Team-membership (write access via merged PRs) and 90-day liveness checks both pass.
Regression Details — signature also on pre-fix stable 0.54.0
The Response stream has been closed PostToolUse-hook error tracked here also appears on stable extension 0.54.0 (VS Code 1.126.0) under a new minification-drift bucket ID. Same throw site (hookResultProcessor.ts:129 → executePostToolUseHook → chatHookService.ts).
Property
Value
Product
VSCode · extension GitHub.copilot-chat
Classification
Expected (pre-fix build) — same as the 0.53.1 recurrence above
Scan range
0.52.0 → 0.54.0 (stable)
Representative bucket
d098daa6 — win32, 86 users, 343 hits (linked in Kusto)
0.54.0 (first seen 2026-05-29) predates fix #321959 (3d575eec, merged 2026-06-19), so it lacks the during-hook cancellation guard — consistent with the errors-fix analysis above. This is a data point for the open "when do stable users receive the fix" question: the 0.54.0 base build does not yet contain it. No reopen, no new issue — linked for continuity.
The Response stream has been closed signature spans 2 buckets on v0.58.0, affecting ~405 users total. Representative bucket ea9710dc (~272 users). Linked to this issue.
Commit-range narrowing is skipped for extension-mode scans.
Activity
vs-code-engineering commentedon Jun 24, 2026
vs-code-engineering commentedon Jun 24, 2026
No fix proposed — already fixed in
mainby #321959 (commit3d575eec); the shipped0.53.1bundle predates that fix. Its bundle lacks the exact 10-line cancellation re-check guard that PR added — confirmed by the deminified call-site offset (chatHookService.ts:513in0.53.1vs:523in fixed source, a 10-line delta that matches PR #321959's+10diff).Summary
The agent-mode PostToolUse hook path throws an unhandled
Response stream has been closed. When a chat request is cancelled while aPostToolUsehook is still running (it spawns external, user-configured commands and can take arbitrarily long), the response stream is already closed by the time the hook resolves;processHookResultsthen writes hook progress/warnings to the now-closed stream, and core'sextHostChatAgents2.tsthrows. This is a recurrence of the already-fixed #321951 / #319003 on a pre-fix build — extension0.53.1(win32, 54 users) does not contain the re-check guard merged tomainon 2026-06-19, so no new code change is warranted.Culprit Commit
This bucket is not a new regression — it is a pre-fix build of a bug already fixed in
main. There is no new culprit commit; the reference fix is:3d575ee+10lines tochatHookService.ts)chatHookService.ts:513in0.53.1is exactly 10 lines above the sameprocessHookResultscall in fixed source (:523); that 10-line delta equals PR #321959's+10guard block, so0.53.1was built without the guard.The underlying race long predates these trackers (it has existed since hook execution moved into the extension);
cdf17eb2(#319011) added a pre-hook cancellation guard, and3d575eec(#321959) closed the remaining during-hook window.Code Flow
sequenceDiagram participant TC as toolCalling.tsx participant CHS as chatHookService.ts participant HRP as hookResultProcessor.ts participant Core as extHostChatAgents2.ts TC->>TC: appendHookContext() pre-hook guard isCancellationRequested? (false) TC->>CHS: executePostToolUseHook(stream, token) CHS->>CHS: await executeHook('PostToolUse') spawns external command (slow) Note over Core: user cancels; finally runs stream.close() sets _isClosed = true Note over CHS: 0.53.1 lacks the post-await re-check guard CHS->>HRP: processHookResults({ outputStream }) HRP->>Core: outputStream.hookProgress(warning) Core-->>HRP: throwIfDone() throws "Response stream has been closed"Affected Files
extensions/copilot/src/extension/intents/node/hookResultProcessor.tsoutputStream.hookProgress(hookType, undefined, formattedWarnings)extensions/copilot/src/extension/chat/vscode-node/chatHookService.tsif (token?.isCancellationRequested) { return undefined; }— absent in0.53.1extensions/copilot/src/extension/prompts/node/panel/toolCalling.tsxawait executePostToolUseHook(...)src/vs/workbench/api/common/extHostChatAgents2.tsstream?.close()runs in thefinallyofraceCancellationWithTimeout(1000, task, token)Repro Steps
PostToolUsehook that runs a non-trivial external command (so it takes a moment to complete).toolCalling.tsxhas already passed).0.53.1): the hook resolves,processHookResultswrites a warning to the now-closed stream, andResponse stream has been closedis thrown to telemetry. On a build with fix: re-check cancellation after postToolUse hook to avoid closed-stream write (fixes #321951) #321959, the post-await guard returns early and no write occurs.Open Questions
Why no fix proposal: the error is already fixed in
mainby #321959 (3d575eec); this bucket is a pre-fix0.53.1build, so there is no source change to make — per the errors-triage "Expected (pre-fix build)" rule, the fix simply needs to reach the0.53.xstable line.Hypotheses to test (only relevant if the bucket persists on a build that does contain #321959):
stream.close()atextHostChatAgents2.ts:1070also runs in thefinallywhen the agent task throws or times out, not only on cancellation. If a PostToolUse hook is still in flight at that moment and the token is not cancelled, the token-based re-check guard would not catch it. Disprove by confirming the tool-calling loop always awaits every in-flight hook before the task settles for non-cancellation reasons.3d575eecwas ported to therelease/0.53branch before0.53.1was cut; if not, every0.53.1user keeps hitting this until they move to a build that includes the fix.Instrumentation to add (so a true post-fix recurrence is distinguishable): the bucket
### Detailsalready records the resolved extension version, which is sufficient to separate pre-fix0.53.1hits from any future post-fix hit. If it does recur at or above the fixed version, enrich the throw atextHostChatAgents2.tsthrowIfDone()with the close reason (cancelled vs completed vs errored) so residual-gap occurrences can be told apart from pre-fix builds without source archaeology.Question for the area owner: was
3d575eec(#321959) cherry-picked into therelease/0.53stable branch, or will0.53.xusers only receive the fix when they upgrade to the next minor?Recommended Owner
@pwang347— owns Chat Hooks pertriage/working-areas.md, authored/owned both prior fixes for this exact path (#319011, #321959), and is an active contributor (committed tochatHookService.tson 2026-06-09, PR #320520). Team-membership (write access via merged PRs) and 90-day liveness checks both pass.vs-code-engineering commentedon Jun 25, 2026
Regression Details — signature also on pre-fix stable
0.54.0The
Response stream has been closedPostToolUse-hook error tracked here also appears on stable extension0.54.0(VS Code1.126.0) under a new minification-drift bucket ID. Same throw site (hookResultProcessor.ts:129→executePostToolUseHook→chatHookService.ts).GitHub.copilot-chat0.53.1recurrence above0.52.0→0.54.0(stable)d098daa6— win32, 86 users, 343 hits (linked in Kusto)0.54.0(first seen 2026-05-29) predates fix #321959 (3d575eec, merged 2026-06-19), so it lacks the during-hook cancellation guard — consistent with the errors-fix analysis above. This is a data point for the open "when do stable users receive the fix" question: the0.54.0base build does not yet contain it. No reopen, no new issue — linked for continuity.vs-code-engineering commentedon Jul 27, 2026
Stable Release Anomaly Details
An automated stable-release anomaly scan (GitHub.copilot-chat v0.58.0 vs previous stable minor v0.57.0) shows this error continuing on v0.58.0.
The
Response stream has been closedsignature spans 2 buckets on v0.58.0, affecting ~405 users total. Representative bucketea9710dc(~272 users). Linked to this issue.Commit-range narrowing is skipped for extension-mode scans.
pwang347 commentedon Sep 17, 2026
Closing as this is on the chat extension