Events never show to the browser when using a ReadableStream
with the text/event-stream
content type
#3232
Labels
ReadableStream
with the text/event-stream
content type
#3232
What version of Remix are you using?
1.5.0
Steps to Reproduce
Create an app using
@remix-run/serve
that returns aReadableStream
body in aloader
, with the content-typetext/event-stream
. Send events.On the client side connect to this endpoint using an
EventSource
.See this reproduction repository for a full example.
The issue appears to be compression in the Express server. If you cURL the endpoint you'll see events streaming as expected:
This pointed me to the underlying problem. cURL doesn't do compression by default. If you enable it, with
curl --compressed
you'll also have a connection that hangs. I'm not sure why but the compression middleware in Express borks streaming responses somehow.If you edit the "@remix-run/serve" server to disable compression for "text/event-stream" content types, things work as expected:
(n.b. there may be a preferable way to do this, I'm not sure.)
While I'm here I should just add that this new streaming functionality is delightful.
Expected Behavior
Events would start to appear via the EventSource connection.
Actual Behavior
No events appear.
The text was updated successfully, but these errors were encountered: