Unverified Commit 4103f837 authored by Janka Uryga's avatar Janka Uryga Committed by GitHub

rename `RenderStage.Runtime` to `PrefetchRuntime` (#99679)

Aligns runtime stage naming with the static stages. We used to call this
the `Runtime` stage, but now we have the concept of navigation stages
("shell"/"prefetch"/"navigation") and we want to align the render stage
names with the navigation stage they correspond to (i.e. which content
they unblock), so it should be called `PrefetchRuntime` now.

(longer-term, i also want to fold `Static*` and `Runtime*` together, and
only use the navigation stage names, but this will take more work, so
we're not doing this now)
parent 1fffea65
...@@ -206,20 +206,20 @@ export async function collectStagedSegmentData( ...@@ -206,20 +206,20 @@ export async function collectStagedSegmentData(
RenderStage.ShellStatic, RenderStage.ShellStatic,
RenderStage.PrefetchStatic, RenderStage.PrefetchStatic,
RenderStage.NavigationStatic, // TODO(cache-stages): only if needed RenderStage.NavigationStatic, // TODO(cache-stages): only if needed
RenderStage.Runtime, RenderStage.PrefetchRuntime,
] ]
break break
} }
case ValidationPrefetchKind.RuntimeAppShell: { case ValidationPrefetchKind.RuntimeAppShell: {
partialStages = [ partialStages = [
RenderStage.ShellRuntime, RenderStage.ShellRuntime,
RenderStage.Runtime, RenderStage.PrefetchRuntime,
RenderStage.NavigationRuntime, // TODO(cache-stages): only if needed RenderStage.NavigationRuntime, // TODO(cache-stages): only if needed
] ]
break break
} }
case ValidationPrefetchKind.LegacySpeculative: { case ValidationPrefetchKind.LegacySpeculative: {
partialStages = [RenderStage.Static, RenderStage.Runtime] partialStages = [RenderStage.Static, RenderStage.PrefetchRuntime]
break break
} }
} }
...@@ -293,7 +293,7 @@ async function collectSegmentDataForStage( ...@@ -293,7 +293,7 @@ async function collectSegmentDataForStage(
case RenderStage.NavigationStatic: case RenderStage.NavigationStatic:
return 'Prerender' return 'Prerender'
case RenderStage.ShellRuntime: // TODO(app-shells) - proper environmentName case RenderStage.ShellRuntime: // TODO(app-shells) - proper environmentName
case RenderStage.Runtime: case RenderStage.PrefetchRuntime:
case RenderStage.NavigationRuntime: case RenderStage.NavigationRuntime:
return 'Prefetch' return 'Prefetch'
case RenderStage.Dynamic: case RenderStage.Dynamic:
...@@ -479,7 +479,7 @@ function onFlightRenderError(error: unknown): string | undefined { ...@@ -479,7 +479,7 @@ function onFlightRenderError(error: unknown): string | undefined {
function createStagedStreamFromChunks(stageChunks: StageChunks) { function createStagedStreamFromChunks(stageChunks: StageChunks) {
// The successive stages are supersets of one another, // The successive stages are supersets of one another,
// so we can index into the dynamic chunks everywhere // so we can index into the dynamic chunks everywhere
// and just look at the lengths of the Static/Runtime arrays // and just look at the lengths of the partial stage arrays
const allChunks = stageChunks[RenderStage.Dynamic] const allChunks = stageChunks[RenderStage.Dynamic]
let chunkIx = 0 let chunkIx = 0
...@@ -986,7 +986,7 @@ export function discoverValidationDepths(loaderTree: LoaderTree): number[] { ...@@ -986,7 +986,7 @@ export function discoverValidationDepths(loaderTree: LoaderTree): number[] {
* Walks the LoaderTree directly, loading modules and counting * Walks the LoaderTree directly, loading modules and counting
* URL-contributing layouts. When `depth` URL segments have been * URL-contributing layouts. When `depth` URL segments have been
* consumed, the boundary flips from shared (dynamic stage) to new * consumed, the boundary flips from shared (dynamic stage) to new
* (static/runtime stage). As the new subtree is built, we check for * (the prefetched stage). As the new subtree is built, we check for
* instant configs. If none are found, returns null — no validation * instant configs. If none are found, returns null — no validation
* needed at this depth or deeper. * needed at this depth or deeper.
* *
...@@ -1024,7 +1024,7 @@ export async function createCombinedPayloadAtDepth( ...@@ -1024,7 +1024,7 @@ export async function createCombinedPayloadAtDepth(
clientReferenceManifest: ClientReferenceManifest, clientReferenceManifest: ClientReferenceManifest,
overrideStageForPartialSegments: overrideStageForPartialSegments:
| null | null
| RenderStage.Runtime | RenderStage.PrefetchRuntime
| RenderStage.NavigationRuntime | RenderStage.NavigationRuntime
): Promise<ValidationPayloadResult | null> { ): Promise<ValidationPayloadResult | null> {
const workStore = workAsyncStorage.getStore() const workStore = workAsyncStorage.getStore()
......
...@@ -10,7 +10,7 @@ export enum RenderStage { ...@@ -10,7 +10,7 @@ export enum RenderStage {
Static = 13, Static = 13,
// //
ShellRuntime = 20, ShellRuntime = 20,
Runtime = 21, PrefetchRuntime = 21,
NavigationRuntime = 22, NavigationRuntime = 22,
// //
Dynamic = 30, Dynamic = 30,
...@@ -29,7 +29,7 @@ export const RENDER_STAGE_ADVANCE_ORDER: AdvanceableRenderStage[] = [ ...@@ -29,7 +29,7 @@ export const RENDER_STAGE_ADVANCE_ORDER: AdvanceableRenderStage[] = [
RenderStage.Static, RenderStage.Static,
// //
RenderStage.ShellRuntime, RenderStage.ShellRuntime,
RenderStage.Runtime, RenderStage.PrefetchRuntime,
RenderStage.NavigationRuntime, RenderStage.NavigationRuntime,
// //
RenderStage.Dynamic, RenderStage.Dynamic,
......
...@@ -747,7 +747,7 @@ class TrackedPromise<T> extends Promise<T> { ...@@ -747,7 +747,7 @@ class TrackedPromise<T> extends Promise<T> {
export const RENDER_STAGES_BY_DATA_KIND = { export const RENDER_STAGES_BY_DATA_KIND = {
sessionData: RenderStage.ShellRuntime as const, sessionData: RenderStage.ShellRuntime as const,
staticLinkData: RenderStage.PrefetchStatic as const, staticLinkData: RenderStage.PrefetchStatic as const,
runtimeLinkData: RenderStage.Runtime as const, runtimeLinkData: RenderStage.PrefetchRuntime as const,
} }
export function applyOwnerStack(error: Error): Error { export function applyOwnerStack(error: Error): Error {
......
...@@ -68,10 +68,10 @@ export function io(expression: string, type: SyncIOApiType) { ...@@ -68,10 +68,10 @@ export function io(expression: string, type: SyncIOApiType) {
break break
} }
case RenderStage.ShellRuntime: case RenderStage.ShellRuntime:
case RenderStage.Runtime: case RenderStage.PrefetchRuntime:
case RenderStage.NavigationRuntime: { case RenderStage.NavigationRuntime: {
// We're in the Runtime stage. // We're in a runtime stage.
// We only error for Sync IO in the Runtime stage if the route has partialPrefetching enabled. // We only error for Sync IO in runtime stages if the route has partialPrefetching enabled.
syncIOError = createSyncIORuntimeError( syncIOError = createSyncIORuntimeError(
workStore.route, workStore.route,
expression, expression,
......
...@@ -433,7 +433,7 @@ function createRuntimePrerenderParams( ...@@ -433,7 +433,7 @@ function createRuntimePrerenderParams(
} }
// Non-root params are URL data, and we need to recover a param-less session shell, // Non-root params are URL data, and we need to recover a param-less session shell,
// so we delay all params until the runtime stage (even if they're static) // so we delay all params until the PrefetchRuntime stage (even if they're static)
const paramsStage = RENDER_STAGES_BY_DATA_KIND.runtimeLinkData const paramsStage = RENDER_STAGES_BY_DATA_KIND.runtimeLinkData
const { stagedRendering } = workUnitStore const { stagedRendering } = workUnitStore
......
...@@ -54,7 +54,7 @@ export function createServerPathnameForMetadata( ...@@ -54,7 +54,7 @@ export function createServerPathnameForMetadata(
// should depend on whether this route has params. // should depend on whether this route has params.
// if there's no params, it can be included. // if there's no params, it can be included.
// for now, we defensively exclude it to match the earlier pessimistic // for now, we defensively exclude it to match the earlier pessimistic
// behavior of always resolving in the runtime stage // behavior of always resolving in the PrefetchRuntime stage
// (i.e. assuming that we have non-static params in the pathname) // (i.e. assuming that we have non-static params in the pathname)
const { stagedRendering } = workUnitStore const { stagedRendering } = workUnitStore
const pathnameStage = RENDER_STAGES_BY_DATA_KIND.runtimeLinkData const pathnameStage = RENDER_STAGES_BY_DATA_KIND.runtimeLinkData
......
...@@ -604,7 +604,7 @@ function makeUntrackedSearchParamsWithDevWarningsImpl( ...@@ -604,7 +604,7 @@ function makeUntrackedSearchParamsWithDevWarningsImpl(
promiseInitialized.current = true promiseInitialized.current = true
}, },
// If we're in staged rendering, this promise will reject if the render // If we're in staged rendering, this promise will reject if the render
// is aborted before it can reach the runtime stage. // is aborted before it can reach the PrefetchRuntime stage.
// In that case, we have to prevent an unhandled rejection from the promise // In that case, we have to prevent an unhandled rejection from the promise
// created by this `.then()` call. // created by this `.then()` call.
// This does not affect the `promiseInitialized` logic above, // This does not affect the `promiseInitialized` logic above,
......
...@@ -2134,7 +2134,7 @@ export async function cache( ...@@ -2134,7 +2134,7 @@ export async function cache(
switch (outerWorkUnitStore.type) { switch (outerWorkUnitStore.type) {
case 'prerender-runtime': { case 'prerender-runtime': {
// In a runtime prerender, we have to make sure that APIs that would hang during a static prerender // In a runtime prerender, we have to make sure that APIs that would hang during a static prerender
// are resolved with a delay, in the appropriate runtime stage. Private caches resolve in EarlyRuntime, // are resolved with a delay, in the appropriate runtime stage.
const stagedRendering = outerWorkUnitStore.stagedRendering const stagedRendering = outerWorkUnitStore.stagedRendering
if (stagedRendering) { if (stagedRendering) {
await stagedRendering.waitForStage( await stagedRendering.waitForStage(
......
...@@ -201,7 +201,7 @@ export function runDevWarmupTests({ ...@@ -201,7 +201,7 @@ export function runDevWarmupTests({
// Static // Static
const STATIC_LINK_DATA = isInitialLoad const STATIC_LINK_DATA = isInitialLoad
? 'Prerender' ? 'Prerender'
: // If we're rendering an App Shell, static params are deferred until the runtime stage. : // If we're rendering an App Shell, static params are deferred until the PrefetchRuntime stage.
partialPrefetching || hasRuntimePrefetch partialPrefetching || hasRuntimePrefetch
? 'Prefetch' ? 'Prefetch'
: 'Prerender' : 'Prerender'
......
...@@ -51,7 +51,7 @@ describe('cache-indicator-partial-prefetching', () => { ...@@ -51,7 +51,7 @@ describe('cache-indicator-partial-prefetching', () => {
const browser = await next.browser('/') const browser = await next.browser('/')
// Cold navigation: the cache read sits after `await params`, so it resolves // Cold navigation: the cache read sits after `await params`, so it resolves
// in the runtime stage, part of the runtime shell for this navigation, so a // in the PrefetchRuntime stage, part of the runtime shell for this navigation, so a
// cold cache there shows the badge. // cold cache there shows the badge.
await browser.elementByCss('a[href="/params/prefetch-auto"]').click() await browser.elementByCss('a[href="/params/prefetch-auto"]').click()
await browser.elementById('params') await browser.elementById('params')
...@@ -69,7 +69,7 @@ describe('cache-indicator-partial-prefetching', () => { ...@@ -69,7 +69,7 @@ describe('cache-indicator-partial-prefetching', () => {
const browser = await next.browser('/') const browser = await next.browser('/')
// Cold navigation: the cache read sits after `await params`, so it resolves // Cold navigation: the cache read sits after `await params`, so it resolves
// in the runtime stage as part of the speculative prefetch shell for this navigation. // in the PrefetchRuntime stage as part of the speculative prefetch shell for this navigation.
// a cold cache there shows the badge. // a cold cache there shows the badge.
await browser.elementByCss('a[href="/params/prefetch-true"]').click() await browser.elementByCss('a[href="/params/prefetch-true"]').click()
await browser.elementById('params') await browser.elementById('params')
......
// A blocking route (`instant = false`) with a dynamic param and no // A blocking route (`instant = false`) with a dynamic param and no
// `generateStaticParams`. The `'use cache'` read sits after `await params`, so // `generateStaticParams`. The `'use cache'` read sits after `await params`, so
// it can only run once the param resolves, in the runtime stage. // it can only run once the param resolves, in the PrefetchRuntime stage.
export const instant = false export const instant = false
async function getCachedValue() { async function getCachedValue() {
......
...@@ -369,7 +369,7 @@ describe('cached navigations', () => { ...@@ -369,7 +369,7 @@ describe('cached navigations', () => {
await page.clock.fastForward(60_000) await page.clock.fastForward(60_000)
// Second navigation — fallback params are deferred to the runtime stage, // Second navigation — fallback params are deferred to the PrefetchRuntime stage,
// so they should NOT be visible while the dynamic request is blocked // so they should NOT be visible while the dynamic request is blocked
await act(async () => { await act(async () => {
await act( await act(
......
...@@ -36,7 +36,7 @@ async function ParamsContent({ ...@@ -36,7 +36,7 @@ async function ParamsContent({
params: Promise<{ slug: string }> params: Promise<{ slug: string }>
}) { }) {
// When the param is a fallback param (not in generateStaticParams), the // When the param is a fallback param (not in generateStaticParams), the
// await is deferred to the runtime stage, so this content won't appear // await is deferred to the PrefetchRuntime stage, so this content won't appear
// in the static stage. // in the static stage.
const { slug } = await params const { slug } = await params
return <p>Param: {slug}</p> return <p>Param: {slug}</p>
......
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