Use static stage end time for static shell validation

parent df76b85a
...@@ -828,6 +828,7 @@ async function generateDynamicFlightRenderResultWithStagesInDev( ...@@ -828,6 +828,7 @@ async function generateDynamicFlightRenderResultWithStagesInDev(
dynamicChunks, dynamicChunks,
staticInterruptReason, staticInterruptReason,
runtimeInterruptReason, runtimeInterruptReason,
staticStageEndTime,
runtimeStageEndTime, runtimeStageEndTime,
debugChannel: returnedDebugChannel, debugChannel: returnedDebugChannel,
requestStore: finalRequestStore, requestStore: finalRequestStore,
...@@ -855,6 +856,7 @@ async function generateDynamicFlightRenderResultWithStagesInDev( ...@@ -855,6 +856,7 @@ async function generateDynamicFlightRenderResultWithStagesInDev(
dynamicChunks, dynamicChunks,
staticInterruptReason, staticInterruptReason,
runtimeInterruptReason, runtimeInterruptReason,
staticStageEndTime,
runtimeStageEndTime, runtimeStageEndTime,
ctx, ctx,
clientReferenceManifest, clientReferenceManifest,
...@@ -2582,6 +2584,7 @@ async function renderToStream( ...@@ -2582,6 +2584,7 @@ async function renderToStream(
dynamicChunks, dynamicChunks,
staticInterruptReason, staticInterruptReason,
runtimeInterruptReason, runtimeInterruptReason,
staticStageEndTime,
runtimeStageEndTime, runtimeStageEndTime,
debugChannel: returnedDebugChannel, debugChannel: returnedDebugChannel,
requestStore: finalRequestStore, requestStore: finalRequestStore,
...@@ -2609,6 +2612,7 @@ async function renderToStream( ...@@ -2609,6 +2612,7 @@ async function renderToStream(
dynamicChunks, dynamicChunks,
staticInterruptReason, staticInterruptReason,
runtimeInterruptReason, runtimeInterruptReason,
staticStageEndTime,
runtimeStageEndTime, runtimeStageEndTime,
ctx, ctx,
clientReferenceManifest, clientReferenceManifest,
...@@ -3202,6 +3206,7 @@ async function renderWithRestartOnCacheMissInDev( ...@@ -3202,6 +3206,7 @@ async function renderWithRestartOnCacheMissInDev(
staticInterruptReason: initialStageController.getStaticInterruptReason(), staticInterruptReason: initialStageController.getStaticInterruptReason(),
runtimeInterruptReason: runtimeInterruptReason:
initialStageController.getRuntimeInterruptReason(), initialStageController.getRuntimeInterruptReason(),
staticStageEndTime: initialStageController.getStaticStageEndTime(),
runtimeStageEndTime: initialStageController.getRuntimeStageEndTime(), runtimeStageEndTime: initialStageController.getRuntimeStageEndTime(),
debugChannel, debugChannel,
requestStore, requestStore,
...@@ -3319,6 +3324,7 @@ async function renderWithRestartOnCacheMissInDev( ...@@ -3319,6 +3324,7 @@ async function renderWithRestartOnCacheMissInDev(
dynamicChunks, dynamicChunks,
staticInterruptReason: finalStageController.getStaticInterruptReason(), staticInterruptReason: finalStageController.getStaticInterruptReason(),
runtimeInterruptReason: finalStageController.getRuntimeInterruptReason(), runtimeInterruptReason: finalStageController.getRuntimeInterruptReason(),
staticStageEndTime: initialStageController.getStaticStageEndTime(),
runtimeStageEndTime: initialStageController.getRuntimeStageEndTime(), runtimeStageEndTime: initialStageController.getRuntimeStageEndTime(),
debugChannel, debugChannel,
requestStore, requestStore,
...@@ -3478,6 +3484,7 @@ async function spawnStaticShellValidationInDev( ...@@ -3478,6 +3484,7 @@ async function spawnStaticShellValidationInDev(
dynamicServerChunks: Array<Uint8Array>, dynamicServerChunks: Array<Uint8Array>,
staticInterruptReason: Error | null, staticInterruptReason: Error | null,
runtimeInterruptReason: Error | null, runtimeInterruptReason: Error | null,
staticStageEndTime: number,
runtimeStageEndTime: number, runtimeStageEndTime: number,
ctx: AppRenderContext, ctx: AppRenderContext,
clientReferenceManifest: NonNullable<RenderOpts['clientReferenceManifest']>, clientReferenceManifest: NonNullable<RenderOpts['clientReferenceManifest']>,
...@@ -3557,17 +3564,11 @@ async function spawnStaticShellValidationInDev( ...@@ -3557,17 +3564,11 @@ async function spawnStaticShellValidationInDev(
debugChannelClient.on('data', (c) => debugChunks.push(c)) 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( const runtimeResult = await validateStagedShell(
runtimeServerChunks, runtimeServerChunks,
dynamicServerChunks, dynamicServerChunks,
debugChunks, debugChunks,
debugEndTime, runtimeStageEndTime,
rootParams, rootParams,
fallbackRouteParams, fallbackRouteParams,
allowEmptyStaticShell, allowEmptyStaticShell,
...@@ -3590,7 +3591,7 @@ async function spawnStaticShellValidationInDev( ...@@ -3590,7 +3591,7 @@ async function spawnStaticShellValidationInDev(
staticServerChunks, staticServerChunks,
dynamicServerChunks, dynamicServerChunks,
debugChunks, debugChunks,
debugEndTime, staticStageEndTime,
rootParams, rootParams,
fallbackRouteParams, fallbackRouteParams,
allowEmptyStaticShell, allowEmptyStaticShell,
......
...@@ -15,6 +15,7 @@ export class StagedRenderingController { ...@@ -15,6 +15,7 @@ export class StagedRenderingController {
naturalStage: RenderStage = RenderStage.Static naturalStage: RenderStage = RenderStage.Static
staticInterruptReason: Error | null = null staticInterruptReason: Error | null = null
runtimeInterruptReason: Error | null = null runtimeInterruptReason: Error | null = null
staticStageEndTime: number = Infinity
runtimeStageEndTime: number = Infinity runtimeStageEndTime: number = Infinity
/** Whether sync IO should interrupt the render */ /** Whether sync IO should interrupt the render */
enableSyncInterrupt = true enableSyncInterrupt = true
...@@ -130,6 +131,10 @@ export class StagedRenderingController { ...@@ -130,6 +131,10 @@ export class StagedRenderingController {
return this.runtimeInterruptReason return this.runtimeInterruptReason
} }
getStaticStageEndTime() {
return this.staticStageEndTime
}
getRuntimeStageEndTime() { getRuntimeStageEndTime() {
return this.runtimeStageEndTime return this.runtimeStageEndTime
} }
...@@ -185,6 +190,7 @@ export class StagedRenderingController { ...@@ -185,6 +190,7 @@ export class StagedRenderingController {
this.currentStage = stage this.currentStage = stage
if (currentStage < RenderStage.Runtime && stage >= RenderStage.Runtime) { if (currentStage < RenderStage.Runtime && stage >= RenderStage.Runtime) {
this.staticStageEndTime = performance.now() + performance.timeOrigin
const runtimeListeners = this.runtimeStageListeners const runtimeListeners = this.runtimeStageListeners
for (let i = 0; i < runtimeListeners.length; i++) { for (let i = 0; i < runtimeListeners.length; i++) {
runtimeListeners[i]() runtimeListeners[i]()
......
...@@ -64,6 +64,7 @@ const fetchRandom = async (entropy: string) => { ...@@ -64,6 +64,7 @@ const fetchRandom = async (entropy: string) => {
'https://next-data-api-endpoint.vercel.app/api/random?b=' + entropy '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. // 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( await fetch(
'https://next-data-api-endpoint.vercel.app/api/random?b=' + entropy + 'x' '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