Skip to content

Stop iterating response body on error for bidirectional streams#668

Closed
SamRemis wants to merge 1 commit intosmithy-lang:developfrom
SamRemis:bugfix-infinite-hang
Closed

Stop iterating response body on error for bidirectional streams#668
SamRemis wants to merge 1 commit intosmithy-lang:developfrom
SamRemis:bugfix-infinite-hang

Conversation

@SamRemis
Copy link
Copy Markdown
Contributor

Issue #, if available:
#657

Description of changes:
On bidirectional HTTP/2 streams, the CRT only signals response body completion when both sides of the stream have sent END_STREAM. When the server returns a non-2xx response (e.g., 429 ThrottlingException), the client side is still open sending events, so get_next_response_chunk() hangs forever waiting for a completion signal that never comes.

This PR updates the CRT HTTP client to break out of the chunks() loop after the first chunk when the response status is >= 400. The error body is already fully buffered by the CRT at that point, allowing the error to be deserialized and raised.

Note: this is a workaround for the CRT not signaling response body completion on half-closed HTTP/2 streams. A complete fix requires the CRT breaking this loop on a half-closed stream. For typical error responses, the body arrives in a single chunk and is fully available before this code runs, but this code will truncate any error response in 2 or more chunks.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@SamRemis SamRemis requested a review from a team as a code owner March 26, 2026 00:09
@SamRemis
Copy link
Copy Markdown
Contributor Author

Note - the CRT team is aware of this issue and is working on it in tandem. Hopefully they fix this upstream and we can never merge this.

@SamRemis SamRemis mentioned this pull request Mar 27, 2026
@SamRemis
Copy link
Copy Markdown
Contributor Author

Closing in favor of #672

@SamRemis SamRemis closed this Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant