Unverified Commit 0db9e5f9 authored by Zack Tanner's avatar Zack Tanner Committed by GitHub

Rename static generation stream option to waitForAllReady (#96564)

## Summary

- rename the `isStaticGeneration` stream option to `waitForAllReady`
- derive the value once from `supportsDynamicResponse` and reuse it
across render paths
- clarify that the option controls waiting for React’s `allReady`,
rather than representing the broader static-generation mode

Stacked on #96563.
parent 7de651e8
...@@ -3296,6 +3296,7 @@ async function renderToStream( ...@@ -3296,6 +3296,7 @@ async function renderToStream(
} = renderOpts } = renderOpts
const { cachedNavigations } = renderOpts.experimental const { cachedNavigations } = renderOpts.experimental
const waitForAllReady = supportsDynamicResponse !== true
const { ServerInsertedHTMLProvider, renderServerInsertedHTML } = const { ServerInsertedHTMLProvider, renderServerInsertedHTML } =
createServerInsertedHTML() createServerInsertedHTML()
...@@ -3886,8 +3887,6 @@ async function renderToStream( ...@@ -3886,8 +3887,6 @@ async function renderToStream(
tracingMetadata: tracingMetadata, tracingMetadata: tracingMetadata,
}) })
const generateStaticHTML = supportsDynamicResponse !== true
const appElement = ( const appElement = (
<App <App
reactServerStream={reactServerResult.tee()} reactServerStream={reactServerResult.tee()}
...@@ -3923,7 +3922,7 @@ async function renderToStream( ...@@ -3923,7 +3922,7 @@ async function renderToStream(
renderToNodeFizzStream, renderToNodeFizzStream,
appElement, appElement,
fizzOptions, fizzOptions,
{ waitForAllReady: generateStaticHTML } { waitForAllReady }
) )
) )
...@@ -3938,7 +3937,7 @@ async function renderToStream( ...@@ -3938,7 +3937,7 @@ async function renderToStream(
nonce, nonce,
formState formState
), ),
isStaticGeneration: generateStaticHTML, waitForAllReady,
allReady, allReady,
deploymentId: ctx.sharedContext.deploymentId, deploymentId: ctx.sharedContext.deploymentId,
getServerInsertedHTML, getServerInsertedHTML,
...@@ -4029,8 +4028,6 @@ async function renderToStream( ...@@ -4029,8 +4028,6 @@ async function renderToStream(
tracingMetadata: tracingMetadata, tracingMetadata: tracingMetadata,
}) })
const generateStaticHTML = supportsDynamicResponse !== true
const appElement = ( const appElement = (
<App <App
reactServerStream={reactServerResult.tee()} reactServerStream={reactServerResult.tee()}
...@@ -4075,7 +4072,7 @@ async function renderToStream( ...@@ -4075,7 +4072,7 @@ async function renderToStream(
nonce, nonce,
formState formState
), ),
isStaticGeneration: generateStaticHTML, waitForAllReady,
allReady, allReady,
deploymentId: ctx.sharedContext.deploymentId, deploymentId: ctx.sharedContext.deploymentId,
getServerInsertedHTML, getServerInsertedHTML,
...@@ -4206,8 +4203,6 @@ async function renderToStream( ...@@ -4206,8 +4203,6 @@ async function renderToStream(
} }
try { try {
const generateStaticHTML = supportsDynamicResponse !== true
const { stream: errorHtmlStream, allReady: errorAllReady } = const { stream: errorHtmlStream, allReady: errorAllReady } =
await workUnitAsyncStorage.run( await workUnitAsyncStorage.run(
requestStore, requestStore,
...@@ -4225,7 +4220,7 @@ async function renderToStream( ...@@ -4225,7 +4220,7 @@ async function renderToStream(
bootstrapScripts: [errorBootstrapScript], bootstrapScripts: [errorBootstrapScript],
formState, formState,
}, },
{ waitForAllReady: generateStaticHTML } { waitForAllReady }
) )
errorAllReady.finally(() => { errorAllReady.finally(() => {
...@@ -4241,7 +4236,7 @@ async function renderToStream( ...@@ -4241,7 +4236,7 @@ async function renderToStream(
nonce, nonce,
formState formState
), ),
isStaticGeneration: generateStaticHTML, waitForAllReady,
deploymentId: ctx.sharedContext.deploymentId, deploymentId: ctx.sharedContext.deploymentId,
getServerInsertedHTML: makeGetServerInsertedHTML({ getServerInsertedHTML: makeGetServerInsertedHTML({
polyfills, polyfills,
...@@ -4304,8 +4299,6 @@ async function renderToStream( ...@@ -4304,8 +4299,6 @@ async function renderToStream(
} }
try { try {
const generateStaticHTML = supportsDynamicResponse !== true
const { stream: errorHtmlStream, allReady: errorAllReady } = const { stream: errorHtmlStream, allReady: errorAllReady } =
await workUnitAsyncStorage.run( await workUnitAsyncStorage.run(
requestStore, requestStore,
...@@ -4338,7 +4331,7 @@ async function renderToStream( ...@@ -4338,7 +4331,7 @@ async function renderToStream(
nonce, nonce,
formState formState
), ),
isStaticGeneration: generateStaticHTML, waitForAllReady,
deploymentId: ctx.sharedContext.deploymentId, deploymentId: ctx.sharedContext.deploymentId,
getServerInsertedHTML: makeGetServerInsertedHTML({ getServerInsertedHTML: makeGetServerInsertedHTML({
polyfills, polyfills,
...@@ -9628,7 +9621,7 @@ async function prerenderToStream( ...@@ -9628,7 +9621,7 @@ async function prerenderToStream(
nonce, nonce,
formState formState
), ),
isStaticGeneration: true, waitForAllReady: true,
getServerInsertedHTML, getServerInsertedHTML,
getServerInsertedMetadata, getServerInsertedMetadata,
deploymentId: ctx.sharedContext.deploymentId, deploymentId: ctx.sharedContext.deploymentId,
...@@ -10167,7 +10160,7 @@ async function prerenderToStream( ...@@ -10167,7 +10160,7 @@ async function prerenderToStream(
nonce, nonce,
formState formState
), ),
isStaticGeneration: true, waitForAllReady: true,
getServerInsertedHTML: makeGetServerInsertedHTML({ getServerInsertedHTML: makeGetServerInsertedHTML({
polyfills, polyfills,
renderServerInsertedHTML, renderServerInsertedHTML,
......
...@@ -695,7 +695,7 @@ export async function continueFizzStream( ...@@ -695,7 +695,7 @@ export async function continueFizzStream(
{ {
suffix, suffix,
inlinedDataStream, inlinedDataStream,
isStaticGeneration, waitForAllReady,
allReady, allReady,
deploymentId, deploymentId,
getServerInsertedHTML, getServerInsertedHTML,
...@@ -706,7 +706,7 @@ export async function continueFizzStream( ...@@ -706,7 +706,7 @@ export async function continueFizzStream(
// Suffix itself might contain close tags at the end, so we need to split it. // Suffix itself might contain close tags at the end, so we need to split it.
const suffixUnclosed = suffix ? suffix.split(CLOSE_TAG, 1)[0] : null const suffixUnclosed = suffix ? suffix.split(CLOSE_TAG, 1)[0] : null
if (isStaticGeneration) { if (waitForAllReady) {
if (allReady) { if (allReady) {
await allReady await allReady
} }
......
...@@ -45,7 +45,7 @@ export type ContinueStreamSharedOptions = { ...@@ -45,7 +45,7 @@ export type ContinueStreamSharedOptions = {
export type ContinueFizzStreamOptions = ContinueStreamSharedOptions & { export type ContinueFizzStreamOptions = ContinueStreamSharedOptions & {
inlinedDataStream: AnyStream | undefined inlinedDataStream: AnyStream | undefined
isStaticGeneration: boolean waitForAllReady: boolean
allReady?: Promise<void> allReady?: Promise<void>
validateRootLayout?: boolean validateRootLayout?: boolean
suffix?: string suffix?: string
......
...@@ -910,7 +910,7 @@ export function chainTransformers<T>( ...@@ -910,7 +910,7 @@ export function chainTransformers<T>(
export type ContinueStreamOptions = { export type ContinueStreamOptions = {
inlinedDataStream: ReadableStream<Uint8Array> | undefined inlinedDataStream: ReadableStream<Uint8Array> | undefined
isStaticGeneration: boolean waitForAllReady: boolean
deploymentId: string | undefined deploymentId: string | undefined
getServerInsertedHTML: () => Promise<string> getServerInsertedHTML: () => Promise<string>
getServerInsertedMetadata: () => Promise<string> getServerInsertedMetadata: () => Promise<string>
...@@ -926,7 +926,7 @@ export async function continueFizzStream( ...@@ -926,7 +926,7 @@ export async function continueFizzStream(
{ {
suffix, suffix,
inlinedDataStream, inlinedDataStream,
isStaticGeneration, waitForAllReady,
deploymentId, deploymentId,
getServerInsertedHTML, getServerInsertedHTML,
getServerInsertedMetadata, getServerInsertedMetadata,
...@@ -936,8 +936,8 @@ export async function continueFizzStream( ...@@ -936,8 +936,8 @@ export async function continueFizzStream(
// Suffix itself might contain close tags at the end, so we need to split it. // Suffix itself might contain close tags at the end, so we need to split it.
const suffixUnclosed = suffix ? suffix.split(CLOSE_TAG, 1)[0] : null const suffixUnclosed = suffix ? suffix.split(CLOSE_TAG, 1)[0] : null
if (isStaticGeneration) { if (waitForAllReady) {
// If we're generating static HTML we need to wait for it to resolve before continuing. // Wait for all Suspense boundaries to resolve before continuing.
await renderStream.allReady await renderStream.allReady
} else { } else {
// Otherwise, we want to make sure Fizz is done with all microtasky work // Otherwise, we want to make sure Fizz is done with all microtasky work
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment