Unverified Commit 89d39c53 authored by Zack Tanner's avatar Zack Tanner Committed by GitHub

Separate App Route render and prerender pipelines (#96662)

## Summary

This introduces explicit `handle()` and `prerender()` entrypoints for
App Routes.

Request and prerender execution now have distinct configuration and Work
Unit paths, removing `executionMode` from the handler context and
eliminating all Work Store execution-mode reads from the App Route
module.

<!-- NEXT_JS_LLM -->
parent faaab1a4
......@@ -197,8 +197,6 @@ export async function handler(
cacheKey = cacheKey === '/index' ? '/' : cacheKey
}
const executionMode = cacheKey !== null ? 'prerender' : 'request'
// Before rendering (which initializes component tree modules), we have to
// set the reference manifests to our global store so Server Action's
// encryption util can access to them at the top level of the page module.
......@@ -233,7 +231,6 @@ export async function handler(
const context: AppRouteRouteHandlerContext = {
params,
previewProps: prerenderManifest.preview,
executionMode,
renderOpts: {
experimental: {
authInterrupts: Boolean(nextConfig.experimental.authInterrupts),
......@@ -295,7 +292,10 @@ export async function handler(
return null
}
const response = await routeModule.handle(nextReq, context)
const response =
cacheKey === null
? await routeModule.handle(nextReq, context)
: await routeModule.prerender(nextReq, context)
;(req as any).fetchMetrics = (context.renderOpts as any).fetchMetrics
let pendingWaitUntil = context.renderOpts.pendingWaitUntil
......@@ -378,7 +378,7 @@ export async function handler(
routePath: srcPage,
routeType: 'route',
revalidateReason: getRevalidateReason({
isStaticGeneration: executionMode === 'prerender',
isStaticGeneration: cacheKey !== null,
isOnDemandRevalidate,
}),
},
......@@ -482,7 +482,7 @@ export async function handler(
routePath: normalizedSrcPage,
routeType: 'route',
revalidateReason: getRevalidateReason({
isStaticGeneration: executionMode === 'prerender',
isStaticGeneration: cacheKey !== null,
isOnDemandRevalidate,
}),
},
......
......@@ -71,7 +71,6 @@ export async function exportAppRoute(
previewModeId: '',
previewModeSigningKey: '',
},
executionMode: 'prerender',
renderOpts: {
cacheComponents,
// app-route handlers don't run instant validation, so the level
......@@ -115,7 +114,7 @@ export async function exportAppRoute(
return { cacheControl: { revalidate: 0, expire: undefined } }
}
const response = await module.handle(request, context)
const response = await module.prerender(request, context)
const isValidStatus = response.status < 400 || response.status === 404
if (!isValidStatus) {
......
......@@ -118,7 +118,6 @@ export class EdgeRouteModuleWrapper {
const context: AppRouteRouteHandlerContext = {
params,
previewProps,
executionMode: 'request',
renderOpts: {
waitUntil,
onClose: closeController.onClose.bind(closeController),
......
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