fix: flush the last SSE event when the stream ends without a blank line - #1216
Open
anxkhn wants to merge 1 commit into
Open
fix: flush the last SSE event when the stream ends without a blank line#1216anxkhn wants to merge 1 commit into
anxkhn wants to merge 1 commit into
Conversation
Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com>
🧪 Code Coverage (vs
|
| Base | PR | Delta | |
|---|---|---|---|
| src/a2a/client/transports/http_helpers.py | 95.54% | 95.69% | 🟢 +0.15% |
| Total | 93.12% | 93.12% | ⚪️ 0.00% |
Generated by coverage-comment.yml
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.
Description
Fixes #1213
Summary
parse_sse_streamonly yields on a blank line. If the peer closes afterdata: {...}with no trailing blank line, leftover payload is dropped.WHATWG SSE requires dispatching a pending event when the connection closes. JsonRpcTransport and RestTransport both use this parser, so a completed Task or Message can vanish and the client waits as if the stream is still open.
After the
aiter_linesloop, ifpayload_chunksis non-empty, the pending event is now yielded the same way a blank line would. Existing tests already send a trailing newline and stay green.Testing
Added
test_parse_sse_stream_flushes_last_event_without_blank_lineintests/client/transports/test_http_helpers.py.4 passed.