fix: guard postToolUse hook against closed response stream (fixes #319003) (#319011)

* fix: guard postToolUse hook against closed response stream (fixes #319003)

When the user cancels a chat request while tools are executing, the
response stream is closed. The postToolUse hook would then attempt to
write warnings via hookProgress to the closed stream, causing an
unhandled 'Response stream has been closed' error.

Add a cancellation token check before executing the postToolUse hook.
If the request is already cancelled, skip the hook entirely since the
stream cannot accept further output.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* fix: replace unicode em-dash with ASCII hyphen in comment

The Compile & Hygiene check failed due to a non-ASCII character (U+2014
em-dash) in a code comment. Replace with a standard hyphen.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: vs-code-engineering[bot] <122617954+vs-code-engineering[bot]@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
vs-code-engineering[bot]
2026-06-09 20:46:23 +00:00
committed by GitHub
parent f9a9359d74
commit cdf17eb2ab
@@ -607,6 +607,11 @@ async function appendHookContext(
return;
}
// Skip postToolUse hook if the request was cancelled - the response stream is closed
if (props.token.isCancellationRequested) {
return;
}
// Execute postToolUse hook after successful tool execution
const postHookResult = await chatHookService.executePostToolUseHook(
props.toolCall.name,