Fix _SameTaskStreamingResponse disconnect test bypassing __init__ - #6627
Merged
danielhanchen merged 2 commits intoJun 24, 2026
Merged
Conversation
test_same_task_response_closes_body_iterator_on_send_disconnect builds the response via __new__ to skip Starlette's __init__, then wires body_iterator, background, and stream_response by hand. It never set _unstarted_cleanup, so the disconnect-before-first-chunk branch of __call__ raised AttributeError instead of ClientDisconnect, failing the Backend CI "Repo tests (CPU)" job on main. Set response._unstarted_cleanup = None in the manual construction, matching the default __init__ assigns.
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
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
The Backend CI "Repo tests (CPU)" job currently fails on
mainwith:The test constructs
_SameTaskStreamingResponsevia__new__to bypass Starlette's__init__, then wiresbody_iterator,background, andstream_responseby hand. It never sets_unstarted_cleanup, so when the simulated disconnect fires before the first body chunk, the unstarted-generator branch of__call__readsself._unstarted_cleanupand raisesAttributeErrorinstead of the expectedClientDisconnect.The implementation is correct; the test was not updated to set the attribute when
_unstarted_cleanupwas added to__init__.Change
Set
response._unstarted_cleanup = Nonein the manual construction, matching the default__init__assigns.Tests
tests/studio/test_stream_cancel_registration_timing.pypasses (25 passed), including the previously failing case.