refactor(ssr): isolate runtime-specific SSR transports#2489
Open
NathanDrake2406 wants to merge 15 commits into
Open
refactor(ssr): isolate runtime-specific SSR transports#2489NathanDrake2406 wants to merge 15 commits into
NathanDrake2406 wants to merge 15 commits into
Conversation
This reverts commit ade9c28.
Node and Web SSR renderer selection is a transport choice, not a deployment runtime target. Naming the shared type as a transport makes the Cloudflare and Nitro mapping clearer while keeping the .web runtime modules generic.\n\nAdd committed bundle assertions for the two main boundary promises: plain Node App builds use the Node renderer transport, and Cloudflare Worker output does not include the Node renderer transport modules.
commit: |
Contributor
Performance benchmarksCompared 0 improved · 0 regressed · 6 within ±1.5%
View detailed results and traces 🟢 improvement · 🔴 regression · ⚫ change below 1.5% · paired base/head |
…derer-transform # Conflicts: # packages/vinext/src/entries/pages-server-entry.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
SsrRenderTransportselects renderer and stream primitives, not deployment ownership.packages/vinext/src/entries/*,packages/vinext/src/server/app-ssr-entry-core.ts,packages/vinext/src/server/app-ssr-render-runtime.*.ts,packages/vinext/src/server/pages-render-runtime.*.ts, stream tests.Why
SSR orchestration should stay shared, but renderer and stream primitives are runtime-specific. Plain Node can use React's Node Fizz transport, while Cloudflare, Nitro, and other Web-compatible targets need Web Stream compatible rendering. Encoding that as a transport seam keeps platform-specific dependencies out of shared lifecycle code.
This refactor is the first layer of that boundary, not a final Node server rewrite. Today the production handler still returns the existing Web
Response, so Node builds cross back through the current response boundary. Splitting the renderer transport first makes the lower-level runtime difference explicit and testable before any future work changes the Node server handoff itself.SsrRenderTransportfrom Cloudflare/Nitro presence and threads it into App and Pages entries.What changed
app-ssr-entry.nodeorapp-ssr-entry.web.pages-render-runtime.nodeorpages-render-runtime.web.Responseboundary.react-dom/server.edgeand Web Streams isolated.Readable.toWeb()cancellation.Maintainer review path
packages/vinext/src/index.tsandpackages/vinext/src/entries/ssr-render-transport.tsfor the single transport selection rule.packages/vinext/src/entries/app-ssr-entry.tsandpackages/vinext/src/entries/pages-server-entry.tsfor generated entry selection.packages/vinext/src/server/app-ssr-entry-core.tsfor the shared App SSR orchestration interface.packages/vinext/src/server/app-ssr-render-runtime.node.tsand.web.tsfor App renderer transport differences.packages/vinext/src/server/app-ssr-stream.tsandapp-ssr-stream-node.tsfor shared insertion state and thin stream adapters.packages/vinext/src/server/pages-render-runtime.node.tsand.web.tsfor Pages render transport selection.tests/node-render-runtime.test.ts,tests/prerender.test.ts, and stream tests for bundle and cancellation boundaries.Validation
vp check packages/vinext/src/entries/app-ssr-entry.ts packages/vinext/src/entries/pages-server-entry.ts packages/vinext/src/entries/ssr-render-transport.ts packages/vinext/src/index.ts tests/node-render-runtime.test.ts tests/prerender.test.tsvp run knipvp test run tests/node-render-runtime.test.ts tests/entry-templates.test.ts tests/app-router-next-config-codegen.test.tsvp test run tests/prerender.test.ts -t "Cloudflare Workers hybrid build"vp test run tests/node-fizz-stream.test.ts tests/app-ssr-stream.test.ts tests/rsc-streaming.test.tsNote: repo-wide
vp checkcurrently fails outside this PR on missing@cloudflare/kumo/components/tabletypes inapps/web/app/benchmarks/.... Touched-file checks, targeted runtime tests, the Cloudflare fixture test, and knip pass.Risk / compatibility
Responseboundary.@vitejs/plugin-rsc/ssr.Non-goals
IncomingMessage -> ServerResponserewrite.Request/Responseproduction boundary.Responsehandoff invinext start; this PR deliberately stops at the SSR renderer transport seam.