You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: SSE client drops the last event when the stream ends without a blank line #1213
parse_sse_stream in src/a2a/client/transports/http_helpers.py only yields an event when it sees a blank line. If the peer closes the connection after data: {...} with no trailing blank line, leftover payload_chunks are thrown away.
WHATWG SSE says a pending event must be dispatched when the connection closes. JsonRpcTransport and RestTransport both use this parser, so a completed Task/Message can vanish and the client sits there as if the stream is still open.
Repro
Feed parse_sse_stream a response whose last lines are data: {"task":{...}} with no following empty line.
Exhaust the generator.
Observed: zero events.
Expected: one ("message", "{...}") event.
Existing tests always send a trailing \n, so this path is untested.
Relevant log output
n/a. Unit-reproducible in tests/client/transports/test_http_helpers.py.
Hi @anxkhn , Thanks for opening both the issue and contributing towards the fix. Until the PR gets reviewed you could on Server-Side
ensure the streaming endpoint explicitly appends a final blank line after the last data: frame before terminating the HTTP response.
If consuming third-party streams on the client side you can wrap the raw byte/line stream before passing it to the SSE parser to inject an artificial trailing newline when the connection closes. This forces the parser to flush and yield the final buffered event before exiting.
Assigning the issue to you till the PR gets reviewed.
Activity
rohityan commentedon Aug 29, 2026
Hi @anxkhn , Thanks for opening both the issue and contributing towards the fix. Until the PR gets reviewed you could on Server-Side
ensure the streaming endpoint explicitly appends a final blank line after the last data: frame before terminating the HTTP response.
If consuming third-party streams on the client side you can wrap the raw byte/line stream before passing it to the SSE parser to inject an artificial trailing newline when the connection closes. This forces the parser to flush and yield the final buffered event before exiting.
Assigning the issue to you till the PR gets reviewed.
mykytanetipa commentedon Aug 30, 2026
@anxkhn The rationale is inverted. WHATWG SSE (9.2.6, https://html.spec.whatwg.org/multipage/server-sent-events.html#event-stream-interpretation) requires the opposite: "Once the end of the file is reached, any pending data must be discarded. (If the file ends in the middle of an event, before the final empty line, the incomplete event is not dispatched.)"
So the parser is already correct, the client should discard an unterminated trailing event.