Skip to content

A leading UTF-8 BOM prevents streaming messages from reading the first event #1982

Description

@sylvesterkaczmarek

A valid event stream prefixed with the UTF-8 bytes EF BB BF does not recognize its first field. If that field is event: message_start, the accumulator can miss the start event; if it is data:, JSON parsing can fail because the first payload was ignored.

Reproduce by prefixing the existing basic_response.txt fixture and serving it through a mocked messages endpoint. Both synchronous/asynchronous and stable/beta streaming helpers fail. The same fixture without the prefix works.

The SSE interpretation algorithm removes one leading BOM, while later U+FEFF characters remain content. Reference: https://html.spec.whatwg.org/multipage/server-sent-events.html#event-stream-interpretation.

Forty-eight real-client regression cases cover first-field order, transport chunking, sync/async and stable/beta helpers. The 24 prefixed cases fail on unchanged main and the 24 unprefixed controls pass. The fixture also includes U+FEFF in response text and a later field name. No live API calls are involved.

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