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(
RenderStage.ShellStatic,
RenderStage.PrefetchStatic,
RenderStage.NavigationStatic, // TODO(cache-stages): only if needed
RenderStage.Runtime,
RenderStage.PrefetchRuntime,
]
break
}
case ValidationPrefetchKind.RuntimeAppShell: {
partialStages = [
RenderStage.ShellRuntime,
RenderStage.Runtime,
RenderStage.PrefetchRuntime,
RenderStage.NavigationRuntime, // TODO(cache-stages): only if needed
]
break
}
case ValidationPrefetchKind.LegacySpeculative: {
partialStages = [RenderStage.Static, RenderStage.Runtime]
partialStages = [RenderStage.Static, RenderStage.PrefetchRuntime]
break
}
}
......@@ -293,7 +293,7 @@ async function collectSegmentDataForStage(
case RenderStage.NavigationStatic:
return 'Prerender'
case RenderStage.ShellRuntime: // TODO(app-shells) - proper environmentName
case RenderStage.Runtime:
case RenderStage.PrefetchRuntime:
case RenderStage.NavigationRuntime:
return 'Prefetch'
case RenderStage.Dynamic:
......@@ -479,7 +479,7 @@ function onFlightRenderError(error: unknown): string | undefined {
function createStagedStreamFromChunks(stageChunks: StageChunks) {
// The successive stages are supersets of one another,
// 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]
let chunkIx = 0
......@@ -986,7 +986,7 @@ export function discoverValidationDepths(loaderTree: LoaderTree): number[] {
* Walks the LoaderTree directly, loading modules and counting
* URL-contributing layouts. When `depth` URL segments have been
* 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
* needed at this depth or deeper.
*
......@@ -1024,7 +1024,7 @@ export async function createCombinedPayloadAtDepth(
clientReferenceManifest: ClientReferenceManifest,
overrideStageForPartialSegments:
| null
| RenderStage.Runtime
| RenderStage.PrefetchRuntime
| RenderStage.NavigationRuntime
): Promise<ValidationPayloadResult | null> {
const workStore = workAsyncStorage.getStore()
......
......@@ -10,7 +10,7 @@ export enum RenderStage {
Static = 13,
//
ShellRuntime = 20,
Runtime = 21,
PrefetchRuntime = 21,
NavigationRuntime = 22,
//
Dynamic = 30,
......@@ -29,7 +29,7 @@ export const RENDER_STAGE_ADVANCE_ORDER: AdvanceableRenderStage[] = [
RenderStage.Static,
//
RenderStage.ShellRuntime,
RenderStage.Runtime,
RenderStage.PrefetchRuntime,
RenderStage.NavigationRuntime,
//
RenderStage.Dynamic,
......
......@@ -747,7 +747,7 @@ class TrackedPromise<T> extends Promise<T> {
export const RENDER_STAGES_BY_DATA_KIND = {
sessionData: RenderStage.ShellRuntime as const,
staticLinkData: RenderStage.PrefetchStatic as const,
runtimeLinkData: RenderStage.Runtime as const,
runtimeLinkData: RenderStage.PrefetchRuntime as const,
}
export function applyOwnerStack(error: Error): Error {
......
......@@ -68,10 +68,10 @@ export function io(expression: string, type: SyncIOApiType) {
break
}
case RenderStage.ShellRuntime:
case RenderStage.Runtime:
case RenderStage.PrefetchRuntime:
case RenderStage.NavigationRuntime: {
// We're in the Runtime stage.
// We only error for Sync IO in the Runtime stage if the route has partialPrefetching enabled.
// We're in a runtime stage.
// We only error for Sync IO in runtime stages if the route has partialPrefetching enabled.
syncIOError = createSyncIORuntimeError(
workStore.route,
expression,
......
......@@ -433,7 +433,7 @@ function createRuntimePrerenderParams(
}
// 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 { stagedRendering } = workUnitStore
......
......@@ -54,7 +54,7 @@ export function createServerPathnameForMetadata(
// should depend on whether this route has params.
// if there's no params, it can be included.
// 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)
const { stagedRendering } = workUnitStore
const pathnameStage = RENDER_STAGES_BY_DATA_KIND.runtimeLinkData
......
......@@ -604,7 +604,7 @@ function makeUntrackedSearchParamsWithDevWarningsImpl(
promiseInitialized.current = true
},
// 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
// created by this `.then()` call.
// This does not affect the `promiseInitialized` logic above,
......
......@@ -2134,7 +2134,7 @@ export async function cache(
switch (outerWorkUnitStore.type) {
case 'prerender-runtime': {
// 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
if (stagedRendering) {
await stagedRendering.waitForStage(
......
......@@ -201,7 +201,7 @@ export function runDevWarmupTests({
// Static
const STATIC_LINK_DATA = isInitialLoad
? '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
? 'Prefetch'
: 'Prerender'
......
......@@ -51,7 +51,7 @@ describe('cache-indicator-partial-prefetching', () => {
const browser = await next.browser('/')
// 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.
await browser.elementByCss('a[href="/params/prefetch-auto"]').click()
await browser.elementById('params')
......@@ -69,7 +69,7 @@ describe('cache-indicator-partial-prefetching', () => {
const browser = await next.browser('/')
// 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.
await browser.elementByCss('a[href="/params/prefetch-true"]').click()
await browser.elementById('params')
......
// A blocking route (`instant = false`) with a dynamic param and no
// `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
async function getCachedValue() {
......
......@@ -369,7 +369,7 @@ describe('cached navigations', () => {
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
await act(async () => {
await act(
......
......@@ -36,7 +36,7 @@ async function ParamsContent({
params: Promise<{ slug: string }>
}) {
// 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.
const { slug } = await params
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