Use static stage end time for static shell validation

parent df76b85a
......@@ -828,6 +828,7 @@ async function generateDynamicFlightRenderResultWithStagesInDev(
dynamicChunks,
staticInterruptReason,
runtimeInterruptReason,
staticStageEndTime,
runtimeStageEndTime,
debugChannel: returnedDebugChannel,
requestStore: finalRequestStore,
......@@ -855,6 +856,7 @@ async function generateDynamicFlightRenderResultWithStagesInDev(
dynamicChunks,
staticInterruptReason,
runtimeInterruptReason,
staticStageEndTime,
runtimeStageEndTime,
ctx,
clientReferenceManifest,
......@@ -2582,6 +2584,7 @@ async function renderToStream(
dynamicChunks,
staticInterruptReason,
runtimeInterruptReason,
staticStageEndTime,
runtimeStageEndTime,
debugChannel: returnedDebugChannel,
requestStore: finalRequestStore,
......@@ -2609,6 +2612,7 @@ async function renderToStream(
dynamicChunks,
staticInterruptReason,
runtimeInterruptReason,
staticStageEndTime,
runtimeStageEndTime,
ctx,
clientReferenceManifest,
......@@ -3202,6 +3206,7 @@ async function renderWithRestartOnCacheMissInDev(
staticInterruptReason: initialStageController.getStaticInterruptReason(),
runtimeInterruptReason:
initialStageController.getRuntimeInterruptReason(),
staticStageEndTime: initialStageController.getStaticStageEndTime(),
runtimeStageEndTime: initialStageController.getRuntimeStageEndTime(),
debugChannel,
requestStore,
......@@ -3319,6 +3324,7 @@ async function renderWithRestartOnCacheMissInDev(
dynamicChunks,
staticInterruptReason: finalStageController.getStaticInterruptReason(),
runtimeInterruptReason: finalStageController.getRuntimeInterruptReason(),
staticStageEndTime: initialStageController.getStaticStageEndTime(),
runtimeStageEndTime: initialStageController.getRuntimeStageEndTime(),
debugChannel,
requestStore,
......@@ -3478,6 +3484,7 @@ async function spawnStaticShellValidationInDev(
dynamicServerChunks: Array<Uint8Array>,
staticInterruptReason: Error | null,
runtimeInterruptReason: Error | null,
staticStageEndTime: number,
runtimeStageEndTime: number,
ctx: AppRenderContext,
clientReferenceManifest: NonNullable<RenderOpts['clientReferenceManifest']>,
......@@ -3557,17 +3564,11 @@ async function spawnStaticShellValidationInDev(
debugChannelClient.on('data', (c) => debugChunks.push(c))
}
// For both runtime and static validation we use the same end time which is
// when the runtime stage ended. This ensures that any I/O that is awaited
// (start of the await) in the dynamic stage won't be considered by React when
// constructing the owner stacks that we use for the validation errors.
const debugEndTime = runtimeStageEndTime
const runtimeResult = await validateStagedShell(
runtimeServerChunks,
dynamicServerChunks,
debugChunks,
debugEndTime,
runtimeStageEndTime,
rootParams,
fallbackRouteParams,
allowEmptyStaticShell,
......@@ -3590,7 +3591,7 @@ async function spawnStaticShellValidationInDev(
staticServerChunks,
dynamicServerChunks,
debugChunks,
debugEndTime,
staticStageEndTime,
rootParams,
fallbackRouteParams,
allowEmptyStaticShell,
......
......@@ -15,6 +15,7 @@ export class StagedRenderingController {
naturalStage: RenderStage = RenderStage.Static
staticInterruptReason: Error | null = null
runtimeInterruptReason: Error | null = null
staticStageEndTime: number = Infinity
runtimeStageEndTime: number = Infinity
/** Whether sync IO should interrupt the render */
enableSyncInterrupt = true
......@@ -130,6 +131,10 @@ export class StagedRenderingController {
return this.runtimeInterruptReason
}
getStaticStageEndTime() {
return this.staticStageEndTime
}
getRuntimeStageEndTime() {
return this.runtimeStageEndTime
}
......@@ -185,6 +190,7 @@ export class StagedRenderingController {
this.currentStage = stage
if (currentStage < RenderStage.Runtime && stage >= RenderStage.Runtime) {
this.staticStageEndTime = performance.now() + performance.timeOrigin
const runtimeListeners = this.runtimeStageListeners
for (let i = 0; i < runtimeListeners.length; i++) {
runtimeListeners[i]()
......
......@@ -64,6 +64,7 @@ const fetchRandom = async (entropy: string) => {
'https://next-data-api-endpoint.vercel.app/api/random?b=' + entropy
)
// The error should point at the fetch above, and not at the following fetch.
// FIXME: On the first load after starting the dev server that doesn't work.
await fetch(
'https://next-data-api-endpoint.vercel.app/api/random?b=' + entropy + 'x'
)
......
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