Skip to content

Streaming fails on SSE control-only events with empty data #3833

Description

@sylvesterkaczmarek

SSEDecoder can legitimately yield an event with empty data for control-only blocks such as id: or retry:. Stream.__stream__() and AsyncStream.__stream__() currently pass every yielded event to sse.json(), so a control-only block terminates an otherwise valid stream with a JSON decoding error before the next API data event is processed.

Example wire sequence:

retry: 1000

data: {}

Expected behavior: OpenAI JSON stream processing should ignore control-only SSE records with empty data and continue to the next data event. Decoder state such as event ID and retry may still be preserved at the SSE layer.

Actual behavior: the stream attempts to parse the empty control record as JSON and fails.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    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