Skip to content

Commit

Permalink
chore: flush headers for event-stream responses
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob-ebey committed Oct 9, 2023
1 parent 960511a commit d506d4a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/express-flush-stream-headers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@remix-run/express": patch
---

Flush headers for text/event-stream responses.
4 changes: 4 additions & 0 deletions packages/remix-express/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ export async function sendRemixResponse(
res.append(key, value);
}

if (nodeResponse.headers.get("Content-Type")?.match(/text\/event-stream/i)) {
res.flushHeaders();
}

if (nodeResponse.body) {
await writeReadableStreamToWritable(nodeResponse.body, res);
} else {
Expand Down

0 comments on commit d506d4a

Please sign in to comment.