File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -293,13 +293,12 @@ export async function build() {
293293 let appRscStream : ReadableStream < Uint8Array > ;
294294
295295 if ( ssrEnabled ) {
296- // SSR on: both streams have full tree
297- rootRscStream = renderToReadableStream < RscPayload > ( {
296+ // SSR on: render the full tree once and tee the stream — one branch
297+ // for SSR HTML, one for the app RSC payload. Rendering twice would
298+ // execute every server component (and defer()) twice per entry (#147).
299+ [ rootRscStream , appRscStream ] = renderToReadableStream < RscPayload > ( {
298300 root : < Root > { appNode } </ Root > ,
299- } ) ;
300- appRscStream = renderToReadableStream < RscPayload > ( {
301- root : < Root > { appNode } </ Root > ,
302- } ) ;
301+ } ) . tee ( ) ;
303302 } else {
304303 // SSR off: root stream has shell, app stream has App only
305304 rootRscStream = renderToReadableStream < RscPayload > ( {
You can’t perform that action at this time.
0 commit comments