Skip to content

[Bug]: CR-terminated SSE events wait for another chunk before delivery #1494

Open

Description

@Elon-Jiang

What happened?

On main a6dd087d04edb6d6a05c899afb0c621d0f456b70, JsonRpcTransport.send_message_streaming() does not yield a complete SSE event ending in two CR characters while the response stays open. LF and CRLF controls yield immediately. A peer waiting for the client to act on that event can consequently stall.

_aiter_sse_lines holds a trailing CR until another chunk or EOF. CR is already a complete line ending under the SSE parsing rules; only an immediately following LF needs to be skipped.

A regression uses a real HTTPX client with MockTransport returning an AsyncByteStream: it yields a valid JSON-RPC message encoded as data: <JSON>\r\r, then waits indefinitely. Calling anext(transport.send_message_streaming(request)) times out; replacing the delimiter with LF or CRLF returns the message without closing the response. The transport, request serialization, SSE parsing and protobuf result decoding all run unchanged; only the remote HTTP response is a fixture. No hosted Agent was tested.

Relevant log output

b'\n' DELIVERED hello before EOF
b'\r\n' DELIVERED hello before EOF
b'\r' TIMEOUT: complete event not delivered

The added client regression fails only for CR on the unchanged baseline (1 failed, 7 passed including framing controls). Existing complete-body tests do not expose this delay because EOF flushes the held CR.

I checked all 68 open PR file lists, behavior searches and the 12 commits touching the helper. #1489 changes UTF-8 decoding and retains the held-CR behavior; #1259 concerns a leading BOM. This report concerns dispatch timing.

Prepared with an AI coding assistant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions