mirror of
https://github.com/microsoft/vscode.git
synced 2026-07-04 22:05:32 +01:00
3d575eec6f
fix: re-check cancellation after postToolUse hook to avoid closed stream write (fixes #321951)
The postToolUse hook can run for a long time because it spawns external,
user-configured commands. If the chat request is cancelled while the hook
runs, the response stream is closed by the time the hook resolves, and
writing hook progress to it throws an unhandled "Response stream has been
closed" error.
The prior fix (cdf17eb2, #319011) only checked cancellation before invoking
the hook, leaving the cancellation-during-hook window open. Re-check the
cancellation token in executePostToolUseHook after the await and skip result
processing when cancelled, since a cancelled turn never consumes the result.
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>