Fix EventStream initial message handling to prevent hangs#4440
Open
Fix EventStream initial message handling to prevent hangs#4440
Conversation
Fixes #4435 Previously, codegen would always call `try_recv_initial()` for event streams, which would block waiting for an initial-request or initial-response message. This caused hangs when operations didn't have modeled initial messages. **Changes:** Runtime (aws-smithy-http & aws-smithy-legacy-http): - `recv()` now filters out initial-request/initial-response messages and stores them in a separate buffer - `try_recv_initial()` checks the buffer first before blocking - Initial messages are discarded if never explicitly read - Added `try_recv_initial_with_preprocessor()` to legacy version for SigV4 support Codegen: - Server: Only calls `try_recv_initial()` when `httpBindingResolver.handlesEventStreamInitialRequest()` returns true - Client: Only calls `try_recv_initial_response()` when there's a parser for non-event-stream output members - Uses `let mut receiver = receiver` pattern for conditional mutability Tests: - Added `test_no_hang_without_initial_message()` to verify operations without modeled initial messages don't hang - Added `test_waits_for_initial_message_when_modeled()` to verify operations with modeled initial messages still block correctly - Added `wait_for_response_ready()` to ManualEventStreamClient for testing connection readiness Documentation: - Updated AGENTS.md with EventStream initial message handling behavior - Added conditional mutability pattern to AGENTS.md
|
A new generated diff is ready to view.
A new doc preview is ready to view. |
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.
Fixes #4435
Previously, codegen would always call
try_recv_initial()for event streams, which would block waiting for an initial-request or initial-response message. This caused hangs when operations didn't have modeled initial messages.Changes:
Runtime (aws-smithy-http & aws-smithy-legacy-http):
recv()now filters out initial-request/initial-response messages and stores them in a separate buffertry_recv_initial()checks the buffer first before blockingtry_recv_initial_with_preprocessor()to legacy version for SigV4 supportCodegen:
try_recv_initial()whenhttpBindingResolver.handlesEventStreamInitialRequest()returns truetry_recv_initial_response()when there's a parser for non-event-stream output membersTests:
test_no_hang_without_initial_message()to verify operations without modeled initial messages don't hangtest_waits_for_initial_message_when_modeled()to verify operations with modeled initial messages still block correctlywait_for_response_ready()to ManualEventStreamClient for testing connection readinessDocumentation:
Motivation and Context
Description
Testing
Checklist
.changelogdirectory, specifying "client," "server," or both in theapplies_tokey..changelogdirectory, specifying "aws-sdk-rust" in theapplies_tokey.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.