Repository navigation
fix(streaming): stop writing workflow stream frames after the client cancels - #9197
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
[Medium impact] The PR appears safe to merge. SummaryStops workflow response writes after the client cancels.
|
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
cancel()closes the controller, butstart()kept enqueueing frames: the "Client cancelled request" error,final,[DONE], chunk/thinking/tool frames, and selected-output frames fromonBlockCompleteInvalid state: Controller is already closed. The terminal path logged a spurious "Stream error" (the catch's own enqueue then threw out ofstart()), and the block-completion path logged "Failed to materialize selected output" and rejected the executor callback. It also finished selected-output materialization and base64 hydration for a client that was already gonecancel()now sets astreamCancelledflag first. Every enqueue instart()goes through one helper that does nothing once the stream is cancelled,controller.close()is skipped after cancel, andonBlockCompletereturns early (and stops between descriptors) before any materialization workcancel()does is unchanged: abort propagation, keepalive stop, base64 cache cleanup, and marking the logging session failed with "Client cancelled request". A client that stays connected gets byte-identical outputType of Change
Testing
streaming.test.ts: cancel the reader mid-execution, run the capturedonBlockCompletewith a selected output, then resolve the execution as cancelled. It asserts the callback resolves and no "Stream error" is loggedController is already closed. With only that assertion relaxed, the "Stream error" assertion fails on its ownstreaming.test.ts: 32/32 passing.check:comment-hygieneandcheck:test-patternscleanChecklist
test-auditauthoring gate)