mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #514] [MERGED] fix: Pages Router SSR streaming #637
Labels
No labels
enhancement
enhancement
good first issue
help wanted
nextjs-tracking
nextjs-tracking
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vinext#637
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/cloudflare/vinext/pull/514
Author: @JaredStowell
Created: 3/13/2026
Status: ✅ Merged
Merged: 3/22/2026
Merged by: @southpolesteve
Base:
main← Head:jstowell/pages-prod-ssr-streaming📝 Commits (10+)
914e483fix pages router streaming4565b58handle regressions25dc13afix: align pages response merge behaviord2b4655fix: drop stale worker content-length headers4877173fix: preserve no-body rewrite parity46e7de5Merge upstream/main into jstowell/pages-prod-ssr-streaming7def74cfix: cancel streamed HEAD responses552e07ctest: support merged prod server shapef0dd479Merge upstream/main into jstowell/pages-prod-ssr-streaming596f0aeFix compressed Pages SSR streaming📊 Changes
13 files changed (+1432 additions, -82 deletions)
View changed files
📝
packages/vinext/src/deploy.ts(+52 -4)📝
packages/vinext/src/entries/pages-server-entry.ts(+8 -1)📝
packages/vinext/src/server/prod-server.ts(+169 -24)📝
packages/vinext/src/server/worker-utils.ts(+58 -3)📝
tests/__snapshots__/entry-templates.test.ts.snap(+28 -15)📝
tests/deploy.test.ts(+128 -0)📝
tests/ecosystem.test.ts(+1 -1)📝
tests/features.test.ts(+402 -0)📝
tests/fixtures/pages-basic/middleware.ts(+7 -0)📝
tests/fixtures/pages-basic/pages/ssr-res-end.tsx(+3 -1)➕
tests/fixtures/pages-basic/pages/streaming-gssp-content-length.tsx(+39 -0)➕
tests/fixtures/pages-basic/pages/streaming-ssr.tsx(+27 -0)📝
tests/pages-router.test.ts(+510 -33)📄 Description
Fix the Pages Router Node production SSR path so responses stay streamed instead of being fully buffered before send.
Previously, the Pages SSR path in
prod-server.tsdrained the renderedResponsewithresponse.arrayBuffer()before writing it to the socket. That removed progressive streaming, copied the full HTML payload, and increased TTFB and memory usage on large responses.This change preserves the original
Response.bodystream through the existing streamed Node response path and fixes the related response-merge edge cases that showed up once streaming was preserved.Changes
204,205,304) correctly when middleware rewrites a streamed Pages SSR responseContent-Lengthfrom streamed Pages SSR responses, including values inherited from:getServerSidePropsContent-LengthfromgetServerSidePropsContent-Lengthfrom middleware rewritesWhy
Pages Router SSR already produces a streamed
Response, but the Node prod server was materializing that stream into a full buffer before sending it.This PR preserves streaming behavior and also handles the edge cases with the streamed merge path:
204,205, and304Content-Lengthon streamed SSR responsesTesting
pnpm test tests/pages-router.test.tspnpm test tests/features.test.ts -t "mergeWebResponse"pnpm run fmtpnpm run typecheck🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.