Replies: 3 comments 3 replies
-
Hi Samy, In principle there's no reason we shouldn't implement this. But, it will take some engineering effort. We'd have to implement a parser for this format, etc. It may be difficult to find time between everything else on our plate. How widely-used is EventSource today? Does it have benefits over WebSocket, aside from being a simpler underlying protocol? If there is a polyfill that works with Workers and is sufficiently lightweight, one possibility is that we incorporate that polyfill directly into workerd, rather than implement EventSource natively. That would keep the engineering investment minimal. |
Beta Was this translation helpful? Give feedback.
-
Draft implementation in #1782 |
Beta Was this translation helpful? Give feedback.
-
seems to be the same subject i've got some results but it is not usable cloudflare/cloudflare-docs#12195 (comment) |
Beta Was this translation helpful? Give feedback.
-
EventSource
is a good and simple API to easily implement streaming. At the moment, it's easy to generate an event source stream from a Cloudflare Worker, but it's not easy to consume one from a Clouflare Worker.Most polyfills are incompatible with Cloudflare Workers:
event-source-polyfill
usesfetch
options that are not supported by Cloudflare, I'll publish a forkeventsource
relies onhttp
/https
module and doesn't work well with the browserify polyfillsWhile it's definitely possible to make a polyfill of
EventSource
works on Worker, it'd be great if this API could be natively supported, especially as the API surface is light and not browser-specific.It looks like
@cloudflare/ai
also consumes an EventSource API, but it's unclear what polyfill is being used there and if the Cloudflare team could publish it as an open source package.Beta Was this translation helpful? Give feedback.
All reactions