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 #312810
Error: Response stream has been closed at t._push (<REDACTED: user-file-path>/.vscode\extensions\github.copilot-chat-0.45.1\dist\extension.js:1726:24933) at t.push (<REDACTED: user-file-path>/.vscode\extensions\github.copilot-chat-0.45.1\dist\extension.js:1726:26055) at t._push (<REDACTED: user-file-path>/.vscode\extensions\github.copilot-chat-0.45.1\dist\extension.js:1726:24694) at t.progress (<REDACTED: user-file-path>/.vscode\extensions\github.copilot-chat-0.45.1\dist\extension.js:1726:25869) at <REDACTED: user-file-path>/.vscode\extensions\github.copilot-chat-0.45.1\dist\extension.js:6879:30682
The GitHub.copilot-chat extension encounters "Response stream has been closed" when it attempts to push data (via progress(), push(), or other stream methods) to a ChatAgentResponseStream that has already been closed. This is a race condition between the extension's asynchronous response generation and the stream lifecycle managed by VS Code's extension host. The error has been present across many extension versions (0.38.x through 0.45.1) with 56,900 total hits affecting 23,368 users, and is flagged as a stable-channel anomaly indicating a recent spike.
Culprit Commit
No commit range was provided in the issue or comments (the issue was just created with no regression scan follow-up yet). The error is a long-standing race condition present across many extension versions — it is not attributable to a single commit. The hit count has been growing steadily:
Extension Version
Hits
Users
0.39.x
~4,500
~2,600
0.42.x
~13,900
~4,900
0.43.0
10,563
4,161
0.44.x
~18,400
~10,100
0.45.1
3,360 (still accumulating)
1,928
Code Flow
sequenceDiagram
participant Ext as Copilot Chat Extension
participant API as ChatAgentResponseStream (extHostChatAgents2.ts)
participant Host as $invokeAgent
Host->>Ext: agent.invoke(request, context, stream, token)
Ext->>API: stream.progress(value) / stream.push(part)
Note over API: ✅ Stream open, data forwarded
Note over Host: ⚠️ CancellationToken fires<br/>(user stops, navigates away, etc.)
Host->>Host: raceCancellationWithTimeout(1000ms)
Note over Host: Wait 1000ms grace period...
Host->>API: finally { stream.close() }
Note over API: _isClosed = true
Ext->>API: stream.progress(value) [async continuation]
Note over API: 💥 throwIfDone() →<br/>"Response stream has been closed"
Extension code — async handler continues writing after close
Repro Steps
Open VS Code with Copilot Chat extension (any version 0.38+)
Start a Copilot Chat conversation that triggers a long streaming response (e.g., complex code generation)
Cancel the request while the response is still streaming — either by clicking the stop button, starting a new message, or navigating away from the chat
The cancellation token fires, but the extension's async LLM token processing may still have pending microtasks or promises that attempt to call stream.progress() after the 1000ms grace period expires
The error is non-deterministic and depends on timing — it's more likely with slower network responses or during tool invocations that produce multiple async progress updates
Fix Proposal
Two complementary approaches, ideally both:
1. VS Code core — graceful close (primary fix) Fix location: src/vs/workbench/api/common/extHostChatAgents2.ts → throwIfDone() Approach: Instead of throwing an error when the stream is closed, silently ignore the write (or log a warning). The throwIfDone pattern at line 83-88 throws an Error that gets caught by the extension host error telemetry, generating noise. Since the stream closure is an expected lifecycle event (cancellation), writes after close should be a no-op, not a thrown error. This would eliminate all hits for this bucket without any behavior change — the data would simply be discarded since the response is already being abandoned.
2. Copilot Chat extension — check cancellation before writes Fix location: github.copilot-chat extension's stream wrapper (the _push/push/progress methods seen in the stack trace) Approach: Before calling VS Code's stream.progress() or stream.push(), check token.isCancellationRequested and return early. This is a defensive check that prevents the extension from hitting the VS Code error path entirely.
Recommended Owner
@roblourens — owns both the Chat Participant API in VS Code (extHostChatAgents2.ts) and the copilot-chat extension's agentic loop, making them the ideal owner to address both sides of this race condition.
Same error pattern as bucket 60c003f2 tracked in this issue — "Response stream has been closed" in chatResponseStreamImpl.ts. This bucket originates from the Agents product stream (16 users on darwin).
Same error pattern — "Response stream has been closed" in trackEdit/gQt/UGn code path within the Copilot extension. This bucket affects 16 users on win32 (v0.48.2026050506) and is increasing across recent versions. Related to bucket 0c0358ec (same code path, darwin platform).
Trend: Increasing since v0.46.2026042303 (1 → 16 users across 6 extension versions).
The stable-anomaly scan comparing extension GitHub.copilot-chat0.67.0 → 0.68.0 surfaced one additional Response stream has been closed bucket that matches this issue's existing _push/push/progress stream-write race. It has been linked to this issue (not filed as a new issue) and is distinct from the buckets noted in the prior 0.68.0 comments (24105cfa/62b55893/a58b9aea and 25b8e9d8/69d9bfbc).
These additional error buckets are tracked by this issue (v0.68.0):
Same root cause as this issue — content pushed to an already-closed response stream (t._push/t.push/t.progress). Flagged new in 0.68.0 due to bucket-ID drift from minification changes, not a genuinely new defect. No separate issue was filed.
These additional error buckets are tracked by this issue (v0.70.0):
Bucket
Users
Path
2fd85354
192
executePostToolUseHook
376d6042
83
executePostToolUseHook
42ef7b48
35
executePostToolUseHook
cc36c158
86
_push / push / progress
09c2e9d8
69
_push / push / progress
99055981
68
_push / push / progress
3907558c
61
_push / push / progress
83ee61bc
48
_push / push / progress
43febc43
42
_push / push / progress
787003de
30
_push / push / progress
29769f52
30
_push / push / progress
d8f71bd9
22
_push / push / progress
The deminified frames match the existing chatResponseStreamImpl.ts stream-write race, including the already documented post-tool-use hook variant. These are bucket-ID drift, not a distinct defect.
Activity
vs-code-engineering commentedon Apr 27, 2026
vs-code-engineering commentedon Apr 27, 2026
🔍 Error Investigation
Summary
The
GitHub.copilot-chatextension encounters "Response stream has been closed" when it attempts to push data (viaprogress(),push(), or other stream methods) to aChatAgentResponseStreamthat has already been closed. This is a race condition between the extension's asynchronous response generation and the stream lifecycle managed by VS Code's extension host. The error has been present across many extension versions (0.38.x through 0.45.1) with 56,900 total hits affecting 23,368 users, and is flagged as a stable-channel anomaly indicating a recent spike.Culprit Commit
No commit range was provided in the issue or comments (the issue was just created with no regression scan follow-up yet). The error is a long-standing race condition present across many extension versions — it is not attributable to a single commit. The hit count has been growing steadily:
Code Flow
sequenceDiagram participant Ext as Copilot Chat Extension participant API as ChatAgentResponseStream (extHostChatAgents2.ts) participant Host as $invokeAgent Host->>Ext: agent.invoke(request, context, stream, token) Ext->>API: stream.progress(value) / stream.push(part) Note over API: ✅ Stream open, data forwarded Note over Host: ⚠️ CancellationToken fires<br/>(user stops, navigates away, etc.) Host->>Host: raceCancellationWithTimeout(1000ms) Note over Host: Wait 1000ms grace period... Host->>API: finally { stream.close() } Note over API: _isClosed = true Ext->>API: stream.progress(value) [async continuation] Note over API: 💥 throwIfDone() →<br/>"Response stream has been closed"Affected Files
src/vs/workbench/api/common/extHostChatAgents2.ts:85throwIfDone()throws "Response stream has been closed"src/vs/workbench/api/common/extHostChatAgents2.ts:998raceCancellationWithTimeout(1000, ...)races task against cancellationsrc/vs/workbench/api/common/extHostChatAgents2.ts:1046finally { stream?.close() }sets_isClosed = truegithub.copilot-chat/dist/extension.jsRepro Steps
stream.progress()after the 1000ms grace period expiresFix Proposal
Two complementary approaches, ideally both:
1. VS Code core — graceful close (primary fix)
Fix location:
src/vs/workbench/api/common/extHostChatAgents2.ts→throwIfDone()Approach: Instead of throwing an error when the stream is closed, silently ignore the write (or log a warning). The
throwIfDonepattern at line 83-88 throws anErrorthat gets caught by the extension host error telemetry, generating noise. Since the stream closure is an expected lifecycle event (cancellation), writes after close should be a no-op, not a thrown error. This would eliminate all hits for this bucket without any behavior change — the data would simply be discarded since the response is already being abandoned.2. Copilot Chat extension — check cancellation before writes
Fix location:
github.copilot-chatextension's stream wrapper (the_push/push/progressmethods seen in the stack trace)Approach: Before calling VS Code's
stream.progress()orstream.push(), checktoken.isCancellationRequestedand return early. This is a defensive check that prevents the extension from hitting the VS Code error path entirely.Recommended Owner
@roblourens— owns both the Chat Participant API in VS Code (extHostChatAgents2.ts) and the copilot-chat extension's agentic loop, making them the ideal owner to address both sides of this race condition.vs-code-engineering commentedon May 8, 2026
Related Error Buckets
These additional error buckets are tracked by this issue (v0.47.2026050401):
0c0358ecSame error pattern as bucket
60c003f2tracked in this issue — "Response stream has been closed" inchatResponseStreamImpl.ts. This bucket originates from the Agents product stream (16 users on darwin).vs-code-engineering commentedon May 11, 2026
Related Error Buckets
These additional error buckets are tracked by this issue (v0.48.2026050506):
0cf8b951Same error pattern — "Response stream has been closed" in
trackEdit/gQt/UGncode path within the Copilot extension. This bucket affects 16 users on win32 (v0.48.2026050506) and is increasing across recent versions. Related to bucket0c0358ec(same code path, darwin platform).Trend: Increasing since v0.46.2026042303 (1 → 16 users across 6 extension versions).
vs-code-engineering commentedon Oct 1, 2026
vs-code-engineering commentedon Oct 2, 2026
vs-code-engineering commentedon Oct 7, 2026
Related Error Buckets
The stable-anomaly scan comparing extension
GitHub.copilot-chat0.67.0 → 0.68.0 surfaced one additionalResponse stream has been closedbucket that matches this issue's existing_push/push/progressstream-write race. It has been linked to this issue (not filed as a new issue) and is distinct from the buckets noted in the prior 0.68.0 comments (24105cfa/62b55893/a58b9aeaand25b8e9d8/69d9bfbc).These additional error buckets are tracked by this issue (v0.68.0):
25b99b55Same root cause as this issue — content pushed to an already-closed response stream (
t._push/t.push/t.progress). Flaggednewin 0.68.0 due to bucket-ID drift from minification changes, not a genuinely new defect. No separate issue was filed.vs-code-engineering commentedon Oct 19, 2026
Regression Details
GitHub.copilot-chat)newbucket IDs for a continuing error familyThese additional error buckets are tracked by this issue (v0.70.0):
2fd85354executePostToolUseHook376d6042executePostToolUseHook42ef7b48executePostToolUseHookcc36c158_push/push/progress09c2e9d8_push/push/progress99055981_push/push/progress3907558c_push/push/progress83ee61bc_push/push/progress43febc43_push/push/progress787003de_push/push/progress29769f52_push/push/progressd8f71bd9_push/push/progressThe deminified frames match the existing
chatResponseStreamImpl.tsstream-write race, including the already documented post-tool-use hook variant. These are bucket-ID drift, not a distinct defect.