Skip to content

SseMessage

Defined in: sse.ts:20

SSE parsing.

Deliberately NOT EventSource, for three reasons that each cost real behaviour:

  1. EventSource cannot set request headers, so it cannot send st-protocol — negotiation would be query-param-only forever.
  2. EventSource reconnects automatically and silently. On a stream that ends in error that means retrying a request the server already answered definitively, repeatedly, from inside a customer’s page.
  3. EventSource cannot read response headers, so the client could never see which protocol version it actually got.

fetch + a manual parser gives all three back. The cost is ~80 lines, which is a good trade for not having a background reconnect loop we do not control.

data: string

Defined in: sse.ts:24

data: payload, lines joined with “\n”.


event: string

Defined in: sse.ts:22

event: name. Unnamed messages arrive as “message”, per the spec.