deno_std icon indicating copy to clipboard operation
deno_std copied to clipboard

ServerSentEventStream: decoding support

Open mfulton26 opened this issue 1 month ago • 4 comments

Is your feature request related to a problem? Please describe.

EventSource works well for GET with no custom request headers but does not super other HTTP verbs, request bodies, or custom request headers (e.g. Authorization).

Describe the solution you'd like

I want to be able to use the standard Fetch API and pipe its response body stream into a SSE message decoder so that I'm not limited by EventSource.

The encode/decode functions for server sent event message could also be exported and helpful. (Under @std/encoding?)

Describe alternatives you've considered

Use a package like https://github.com/lukeed/fetch-event-stream or roll it myself. Both of these seem less than ideal though given that @std supports encoding and I'd like to get decoding support from the same instead of relying on two sources.

mfulton26 avatar Nov 12 '25 11:11 mfulton26

Do you know about ServerSentEventStream? Disclaimer: I only skimmed this issue.

iuioiua avatar Nov 19 '25 22:11 iuioiua

Do you know about ServerSentEventStream? Disclaimer: I only skimmed this issue.

Yes. This works for encoding but does not support decoding.

mfulton26 avatar Nov 20 '25 03:11 mfulton26

Maybe something like ServerSentEventParseStream in @std/http?

kt3k avatar Nov 27 '25 01:11 kt3k

Yes. These two stream classes could also be named like other encoding/decoding ones: EventEncoderStream and EventDecoderStream.

mfulton26 avatar Nov 27 '25 13:11 mfulton26