Unverified Commit a85d888a authored by Wyatt Johnson's avatar Wyatt Johnson Committed by GitHub

refactor: consolidate PPR into cacheComponents architecture (#88243)

### What?

Removes the `experimental.ppr` configuration flag and consolidates
Partial Prerendering (PPR) functionality into the `cacheComponents`
architecture.

### Why?

Having two separate systems (PPR flag and cacheComponents) created dual
code paths and complexity. PPR is now implicitly enabled when
cacheComponents is enabled, simplifying the codebase.

### How?

- Deleted `postpone.ts` and `ppr.ts` utility files
- Removed `PrerenderStorePPR` work unit type and all PPR-specific work
unit cases
- Removed React.unstable_postpone-based dynamic rendering logic
- Deprecated `experimental.ppr` config (kept for backwards
compatibility)
- Simplified build system to check only `cacheComponents` flag
- Updated tests to remove PPR-specific behavior expectations

This removes ~986 lines of code across 48 files.
parent ee9e6887
...@@ -19,7 +19,6 @@ import { findPagesDir } from '../../lib/find-pages-dir' ...@@ -19,7 +19,6 @@ import { findPagesDir } from '../../lib/find-pages-dir'
import { PAGE_TYPES } from '../../lib/page-types' import { PAGE_TYPES } from '../../lib/page-types'
import loadCustomRoutes from '../../lib/load-custom-routes' import loadCustomRoutes from '../../lib/load-custom-routes'
import { generateRoutesManifest } from '../generate-routes-manifest' import { generateRoutesManifest } from '../generate-routes-manifest'
import { checkIsAppPPREnabled } from '../../server/lib/experimental/ppr'
import { normalizeAppPath } from '../../shared/lib/router/utils/app-paths' import { normalizeAppPath } from '../../shared/lib/router/utils/app-paths'
import http from 'node:http' import http from 'node:http'
...@@ -188,7 +187,7 @@ async function collectRoutesForAnalyze( ...@@ -188,7 +187,7 @@ async function collectRoutesForAnalyze(
config.basePath ? `${config.basePath}${pathPrefix}` : pathPrefix config.basePath ? `${config.basePath}${pathPrefix}` : pathPrefix
) )
const isAppPPREnabled = checkIsAppPPREnabled(config.experimental.ppr) const isAppPPREnabled = !!config.cacheComponents
// Generate routes manifest // Generate routes manifest
const { routesManifest } = generateRoutesManifest({ const { routesManifest } = generateRoutesManifest({
......
...@@ -7,7 +7,6 @@ import type { ProxyMatcher } from './analysis/get-page-static-info' ...@@ -7,7 +7,6 @@ import type { ProxyMatcher } from './analysis/get-page-static-info'
import type { Rewrite } from '../lib/load-custom-routes' import type { Rewrite } from '../lib/load-custom-routes'
import path from 'node:path' import path from 'node:path'
import { needsExperimentalReact } from '../lib/needs-experimental-react' import { needsExperimentalReact } from '../lib/needs-experimental-react'
import { checkIsAppPPREnabled } from '../server/lib/experimental/ppr'
import { import {
getNextConfigEnv, getNextConfigEnv,
getNextPublicEnvironmentVariables, getNextPublicEnvironmentVariables,
...@@ -115,7 +114,6 @@ export function getDefineEnv({ ...@@ -115,7 +114,6 @@ export function getDefineEnv({
const nextPublicEnv = getNextPublicEnvironmentVariables() const nextPublicEnv = getNextPublicEnvironmentVariables()
const nextConfigEnv = getNextConfigEnv(config) const nextConfigEnv = getNextConfigEnv(config)
const isPPREnabled = checkIsAppPPREnabled(config.experimental.ppr)
const isCacheComponentsEnabled = !!config.cacheComponents const isCacheComponentsEnabled = !!config.cacheComponents
const isUseCacheEnabled = !!config.experimental.useCache const isUseCacheEnabled = !!config.experimental.useCache
...@@ -161,7 +159,6 @@ export function getDefineEnv({ ...@@ -161,7 +159,6 @@ export function getDefineEnv({
'process.env.__NEXT_APP_NAV_FAIL_HANDLING': Boolean( 'process.env.__NEXT_APP_NAV_FAIL_HANDLING': Boolean(
config.experimental.appNavFailHandling config.experimental.appNavFailHandling
), ),
'process.env.__NEXT_PPR': isPPREnabled,
'process.env.__NEXT_CACHE_COMPONENTS': isCacheComponentsEnabled, 'process.env.__NEXT_CACHE_COMPONENTS': isCacheComponentsEnabled,
'process.env.__NEXT_USE_CACHE': isUseCacheEnabled, 'process.env.__NEXT_USE_CACHE': isUseCacheEnabled,
......
...@@ -199,10 +199,6 @@ import { traceMemoryUsage } from '../lib/memory/trace' ...@@ -199,10 +199,6 @@ import { traceMemoryUsage } from '../lib/memory/trace'
import { generateEncryptionKeyBase64 } from '../server/app-render/encryption-utils-server' import { generateEncryptionKeyBase64 } from '../server/app-render/encryption-utils-server'
import type { DeepReadonly } from '../shared/lib/deep-readonly' import type { DeepReadonly } from '../shared/lib/deep-readonly'
import uploadTrace from '../trace/upload-trace' import uploadTrace from '../trace/upload-trace'
import {
checkIsAppPPREnabled,
checkIsRoutePPREnabled,
} from '../server/lib/experimental/ppr'
import { FallbackMode, fallbackModeToFallbackField } from '../lib/fallback' import { FallbackMode, fallbackModeToFallbackField } from '../lib/fallback'
import { RenderingMode } from './rendering-mode' import { RenderingMode } from './rendering-mode'
import { InvariantError } from '../shared/lib/invariant-error' import { InvariantError } from '../shared/lib/invariant-error'
...@@ -1596,7 +1592,7 @@ export default async function build( ...@@ -1596,7 +1592,7 @@ export default async function build(
const isAuthInterruptsEnabled = Boolean( const isAuthInterruptsEnabled = Boolean(
config.experimental.authInterrupts config.experimental.authInterrupts
) )
const isAppPPREnabled = checkIsAppPPREnabled(config.experimental.ppr) const isAppPPREnabled = isAppCacheComponentsEnabled
const routesManifestPath = path.join(distDir, ROUTES_MANIFEST) const routesManifestPath = path.join(distDir, ROUTES_MANIFEST)
...@@ -2151,7 +2147,6 @@ export default async function build( ...@@ -2151,7 +2147,6 @@ export default async function build(
locales: config.i18n?.locales, locales: config.i18n?.locales,
defaultLocale: config.i18n?.defaultLocale, defaultLocale: config.i18n?.defaultLocale,
nextConfigOutput: config.output, nextConfigOutput: config.output,
pprConfig: config.experimental.ppr,
cacheLifeProfiles: config.cacheLife, cacheLifeProfiles: config.cacheLife,
buildId, buildId,
sriEnabled, sriEnabled,
...@@ -2373,7 +2368,6 @@ export default async function build( ...@@ -2373,7 +2368,6 @@ export default async function build(
: config.experimental.isrFlushToDisk, : config.experimental.isrFlushToDisk,
cacheMaxMemorySize: config.cacheMaxMemorySize, cacheMaxMemorySize: config.cacheMaxMemorySize,
nextConfigOutput: config.output, nextConfigOutput: config.output,
pprConfig: config.experimental.ppr,
cacheLifeProfiles: config.cacheLife, cacheLifeProfiles: config.cacheLife,
buildId, buildId,
sriEnabled, sriEnabled,
...@@ -2948,9 +2942,8 @@ export default async function build( ...@@ -2948,9 +2942,8 @@ export default async function build(
const appConfig = appDefaultConfigs.get(originalAppPath) const appConfig = appDefaultConfigs.get(originalAppPath)
const isDynamicError = appConfig?.dynamic === 'error' const isDynamicError = appConfig?.dynamic === 'error'
const isRoutePPREnabled: boolean = appConfig const isRoutePPREnabled: boolean =
? checkIsRoutePPREnabled(config.experimental.ppr) !!appConfig && isAppCacheComponentsEnabled
: false
routes.forEach((route) => { routes.forEach((route) => {
// If the route has any dynamic root segments, we need to skip // If the route has any dynamic root segments, we need to skip
...@@ -3139,8 +3132,7 @@ export default async function build( ...@@ -3139,8 +3132,7 @@ export default async function build(
// When this is an app page and PPR is enabled, the route supports // When this is an app page and PPR is enabled, the route supports
// partial pre-rendering. // partial pre-rendering.
const isRoutePPREnabled: true | undefined = const isRoutePPREnabled: true | undefined =
!isAppRouteHandler && !isAppRouteHandler && isAppCacheComponentsEnabled
checkIsRoutePPREnabled(config.experimental.ppr)
? true ? true
: undefined : undefined
......
...@@ -20,7 +20,6 @@ import { BaseServerSpan } from '../../server/lib/trace/constants' ...@@ -20,7 +20,6 @@ import { BaseServerSpan } from '../../server/lib/trace/constants'
import { interopDefault } from '../../server/app-render/interop-default' import { interopDefault } from '../../server/app-render/interop-default'
import { stripFlightHeaders } from '../../server/app-render/strip-flight-headers' import { stripFlightHeaders } from '../../server/app-render/strip-flight-headers'
import { NodeNextRequest, NodeNextResponse } from '../../server/base-http/node' import { NodeNextRequest, NodeNextResponse } from '../../server/base-http/node'
import { checkIsAppPPREnabled } from '../../server/lib/experimental/ppr'
import { import {
getFallbackRouteParams, getFallbackRouteParams,
createOpaqueFallbackRouteParams, createOpaqueFallbackRouteParams,
...@@ -222,12 +221,10 @@ export async function handler( ...@@ -222,12 +221,10 @@ export async function handler(
const isPossibleServerAction = getIsPossibleServerAction(req) const isPossibleServerAction = getIsPossibleServerAction(req)
/** /**
* If the route being rendered is an app page, and the ppr feature has been * If the route being rendered is an app page, and the cacheComponents feature
* enabled, then the given route _could_ support PPR. * has been enabled, then the given route _could_ support PPR.
*/ */
const couldSupportPPR: boolean = checkIsAppPPREnabled( const couldSupportPPR: boolean = !!nextConfig.cacheComponents
nextConfig.experimental.ppr
)
if ( if (
!getRequestMeta(req, 'postponed') && !getRequestMeta(req, 'postponed') &&
......
...@@ -2,8 +2,6 @@ import type { ...@@ -2,8 +2,6 @@ import type {
NextConfigComplete, NextConfigComplete,
NextConfigRuntime, NextConfigRuntime,
} from '../server/config-shared' } from '../server/config-shared'
import type { ExperimentalPPRConfig } from '../server/lib/experimental/ppr'
import { checkIsRoutePPREnabled } from '../server/lib/experimental/ppr'
import type { AssetBinding } from './webpack/loaders/get-module-build-info' import type { AssetBinding } from './webpack/loaders/get-module-build-info'
import type { ServerRuntime } from '../types' import type { ServerRuntime } from '../types'
import type { BuildManifest } from '../server/get-page-files' import type { BuildManifest } from '../server/get-page-files'
...@@ -751,7 +749,6 @@ export async function isPageStatic({ ...@@ -751,7 +749,6 @@ export async function isPageStatic({
cacheHandler, cacheHandler,
cacheHandlers, cacheHandlers,
cacheLifeProfiles, cacheLifeProfiles,
pprConfig,
buildId, buildId,
sriEnabled, sriEnabled,
}: { }: {
...@@ -777,7 +774,6 @@ export async function isPageStatic({ ...@@ -777,7 +774,6 @@ export async function isPageStatic({
[profile: string]: import('../server/use-cache/cache-life').CacheLife [profile: string]: import('../server/use-cache/cache-life').CacheLife
} }
nextConfigOutput: 'standalone' | 'export' | undefined nextConfigOutput: 'standalone' | 'export' | undefined
pprConfig: ExperimentalPPRConfig | undefined
buildId: string buildId: string
sriEnabled: boolean sriEnabled: boolean
}): Promise<PageIsStaticResult> { }): Promise<PageIsStaticResult> {
...@@ -902,12 +898,10 @@ export async function isPageStatic({ ...@@ -902,12 +898,10 @@ export async function isPageStatic({
rootParamKeys = collectRootParamKeys(routeModule) rootParamKeys = collectRootParamKeys(routeModule)
// A page supports partial prerendering if it is an app page and either // A page supports partial prerendering if it is an app page and
// the whole app has PPR enabled or this page has PPR enabled when we're // cacheComponents is enabled.
// in incremental mode.
isRoutePPREnabled = isRoutePPREnabled =
routeModule.definition.kind === RouteKind.APP_PAGE && routeModule.definition.kind === RouteKind.APP_PAGE && cacheComponents
checkIsRoutePPREnabled(pprConfig)
// If force dynamic was set and we don't have PPR enabled, then set the // If force dynamic was set and we don't have PPR enabled, then set the
// revalidate to 0. // revalidate to 0.
......
...@@ -20,7 +20,6 @@ function hasFallbackRouteParams(): boolean { ...@@ -20,7 +20,6 @@ function hasFallbackRouteParams(): boolean {
switch (workUnitStore.type) { switch (workUnitStore.type) {
case 'prerender': case 'prerender':
case 'prerender-client': case 'prerender-client':
case 'prerender-ppr':
const fallbackParams = workUnitStore.fallbackRouteParams const fallbackParams = workUnitStore.fallbackRouteParams
return fallbackParams ? fallbackParams.size > 0 : false return fallbackParams ? fallbackParams.size > 0 : false
case 'prerender-legacy': case 'prerender-legacy':
......
...@@ -167,15 +167,11 @@ export async function fetchServerResponse( ...@@ -167,15 +167,11 @@ export async function fetchServerResponse(
// Typically, during a navigation, we decode the response using Flight's // Typically, during a navigation, we decode the response using Flight's
// `createFromFetch` API, which accepts a `fetch` promise. // `createFromFetch` API, which accepts a `fetch` promise.
// TODO: Remove this check once the old PPR flag is removed
const isLegacyPPR =
process.env.__NEXT_PPR && !process.env.__NEXT_CACHE_COMPONENTS
const shouldImmediatelyDecode = !isLegacyPPR
const res = await createFetch<NavigationFlightResponse>( const res = await createFetch<NavigationFlightResponse>(
url, url,
headers, headers,
'auto', 'auto',
shouldImmediatelyDecode true
) )
const responseUrl = urlToUrlWithoutFlightMarker(new URL(res.url)) const responseUrl = urlToUrlWithoutFlightMarker(new URL(res.url))
......
...@@ -2,10 +2,7 @@ import { isHangingPromiseRejectionError } from '../../server/dynamic-rendering-u ...@@ -2,10 +2,7 @@ import { isHangingPromiseRejectionError } from '../../server/dynamic-rendering-u
import { isPostpone } from '../../server/lib/router-utils/is-postpone' import { isPostpone } from '../../server/lib/router-utils/is-postpone'
import { isBailoutToCSRError } from '../../shared/lib/lazy-dynamic/bailout-to-csr' import { isBailoutToCSRError } from '../../shared/lib/lazy-dynamic/bailout-to-csr'
import { isNextRouterError } from './is-next-router-error' import { isNextRouterError } from './is-next-router-error'
import { import { isPrerenderInterruptedError } from '../../server/app-render/dynamic-rendering'
isDynamicPostpone,
isPrerenderInterruptedError,
} from '../../server/app-render/dynamic-rendering'
import { isDynamicServerError } from './hooks-server-context' import { isDynamicServerError } from './hooks-server-context'
export function unstable_rethrow(error: unknown): void { export function unstable_rethrow(error: unknown): void {
...@@ -13,7 +10,6 @@ export function unstable_rethrow(error: unknown): void { ...@@ -13,7 +10,6 @@ export function unstable_rethrow(error: unknown): void {
isNextRouterError(error) || isNextRouterError(error) ||
isBailoutToCSRError(error) || isBailoutToCSRError(error) ||
isDynamicServerError(error) || isDynamicServerError(error) ||
isDynamicPostpone(error) ||
isPostpone(error) || isPostpone(error) ||
isHangingPromiseRejectionError(error) || isHangingPromiseRejectionError(error) ||
isPrerenderInterruptedError(error) isPrerenderInterruptedError(error)
......
import { isDynamicServerError } from '../../client/components/hooks-server-context' import { isDynamicServerError } from '../../client/components/hooks-server-context'
import { isBailoutToCSRError } from '../../shared/lib/lazy-dynamic/bailout-to-csr' import { isBailoutToCSRError } from '../../shared/lib/lazy-dynamic/bailout-to-csr'
import { isNextRouterError } from '../../client/components/is-next-router-error' import { isNextRouterError } from '../../client/components/is-next-router-error'
import { isDynamicPostpone } from '../../server/app-render/dynamic-rendering'
export const isDynamicUsageError = (err: unknown) => export const isDynamicUsageError = (err: unknown) =>
isDynamicServerError(err) || isDynamicServerError(err) ||
isBailoutToCSRError(err) || isBailoutToCSRError(err) ||
isNextRouterError(err) || isNextRouterError(err)
isDynamicPostpone(err)
...@@ -119,7 +119,6 @@ async function createComponentTreeInternal( ...@@ -119,7 +119,6 @@ async function createComponentTreeInternal(
createServerParamsForServerSegment, createServerParamsForServerSegment,
createPrerenderParamsForClientSegment, createPrerenderParamsForClientSegment,
serverHooks: { DynamicServerError }, serverHooks: { DynamicServerError },
Postpone,
}, },
pagePath, pagePath,
getDynamicParamFromSegment, getDynamicParamFromSegment,
...@@ -304,7 +303,6 @@ async function createComponentTreeInternal( ...@@ -304,7 +303,6 @@ async function createComponentTreeInternal(
case 'prerender': case 'prerender':
case 'prerender-runtime': case 'prerender-runtime':
case 'prerender-legacy': case 'prerender-legacy':
case 'prerender-ppr':
if (workUnitStore.revalidate > defaultRevalidate) { if (workUnitStore.revalidate > defaultRevalidate) {
workUnitStore.revalidate = defaultRevalidate workUnitStore.revalidate = defaultRevalidate
} }
...@@ -689,40 +687,6 @@ async function createComponentTreeInternal( ...@@ -689,40 +687,6 @@ async function createComponentTreeInternal(
} }
const Component = MaybeComponent const Component = MaybeComponent
// If force-dynamic is used and the current render supports postponing, we
// replace it with a node that will postpone the render. This ensures that the
// postpone is invoked during the react render phase and not during the next
// render phase.
// @TODO this does not actually do what it seems like it would or should do. The idea is that
// if we are rendering in a force-dynamic mode and we can postpone we should only make the segments
// that ask for force-dynamic to be dynamic, allowing other segments to still prerender. However
// because this comes after the children traversal and the static generation store is mutated every segment
// along the parent path of a force-dynamic segment will hit this condition effectively making the entire
// render force-dynamic. We should refactor this function so that we can correctly track which segments
// need to be dynamic
if (
workStore.isStaticGeneration &&
workStore.forceDynamic &&
experimental.isRoutePPREnabled
) {
return [
createElement(
Fragment,
{
key: cacheNodeKey,
},
createElement(Postpone, {
reason: 'dynamic = "force-dynamic" was used',
route: workStore.route,
}),
layerAssets
),
parallelRouteCacheNodeSeedData,
loadingData,
true,
hasRuntimePrefetch,
]
}
const isClientComponent = isClientReference(layoutOrPageMod) const isClientComponent = isClientReference(layoutOrPageMod)
......
...@@ -50,8 +50,6 @@ import { scheduleOnNextTick } from '../../lib/scheduler' ...@@ -50,8 +50,6 @@ import { scheduleOnNextTick } from '../../lib/scheduler'
import { BailoutToCSRError } from '../../shared/lib/lazy-dynamic/bailout-to-csr' import { BailoutToCSRError } from '../../shared/lib/lazy-dynamic/bailout-to-csr'
import { InvariantError } from '../../shared/lib/invariant-error' import { InvariantError } from '../../shared/lib/invariant-error'
const hasPostpone = typeof React.unstable_postpone === 'function'
export type DynamicAccess = { export type DynamicAccess = {
/** /**
* If debugging, this will contain the stack trace of where the dynamic access * If debugging, this will contain the stack trace of where the dynamic access
...@@ -143,7 +141,6 @@ export function markCurrentScopeAsDynamic( ...@@ -143,7 +141,6 @@ export function markCurrentScopeAsDynamic(
// A private cache scope is already dynamic by definition. // A private cache scope is already dynamic by definition.
return return
case 'prerender-legacy': case 'prerender-legacy':
case 'prerender-ppr':
case 'request': case 'request':
break break
default: default:
...@@ -164,12 +161,6 @@ export function markCurrentScopeAsDynamic( ...@@ -164,12 +161,6 @@ export function markCurrentScopeAsDynamic(
if (workUnitStore) { if (workUnitStore) {
switch (workUnitStore.type) { switch (workUnitStore.type) {
case 'prerender-ppr':
return postponeWithTracking(
store.route,
expression,
workUnitStore.dynamicTracking
)
case 'prerender-legacy': case 'prerender-legacy':
workUnitStore.revalidate = 0 workUnitStore.revalidate = 0
...@@ -239,7 +230,6 @@ export function trackDynamicDataInDynamicRender(workUnitStore: WorkUnitStore) { ...@@ -239,7 +230,6 @@ export function trackDynamicDataInDynamicRender(workUnitStore: WorkUnitStore) {
case 'prerender': case 'prerender':
case 'prerender-runtime': case 'prerender-runtime':
case 'prerender-legacy': case 'prerender-legacy':
case 'prerender-ppr':
case 'prerender-client': case 'prerender-client':
break break
case 'request': case 'request':
...@@ -335,78 +325,6 @@ export function abortAndThrowOnSynchronousRequestDataAccess( ...@@ -335,78 +325,6 @@ export function abortAndThrowOnSynchronousRequestDataAccess(
) )
} }
/**
* This component will call `React.postpone` that throws the postponed error.
*/
type PostponeProps = {
reason: string
route: string
}
export function Postpone({ reason, route }: PostponeProps): never {
const prerenderStore = workUnitAsyncStorage.getStore()
const dynamicTracking =
prerenderStore && prerenderStore.type === 'prerender-ppr'
? prerenderStore.dynamicTracking
: null
postponeWithTracking(route, reason, dynamicTracking)
}
export function postponeWithTracking(
route: string,
expression: string,
dynamicTracking: null | DynamicTrackingState
): never {
assertPostpone()
if (dynamicTracking) {
dynamicTracking.dynamicAccesses.push({
// When we aren't debugging, we don't need to create another error for the
// stack trace.
stack: dynamicTracking.isDebugDynamicAccesses
? new Error().stack
: undefined,
expression,
})
}
React.unstable_postpone(createPostponeReason(route, expression))
}
function createPostponeReason(route: string, expression: string) {
return (
`Route ${route} needs to bail out of prerendering at this point because it used ${expression}. ` +
`React throws this special object to indicate where. It should not be caught by ` +
`your own try/catch. Learn more: https://nextjs.org/docs/messages/ppr-caught-error`
)
}
export function isDynamicPostpone(err: unknown) {
if (
typeof err === 'object' &&
err !== null &&
typeof (err as any).message === 'string'
) {
return isDynamicPostponeReason((err as any).message)
}
return false
}
function isDynamicPostponeReason(reason: string) {
return (
reason.includes(
'needs to bail out of prerendering at this point because it used'
) &&
reason.includes(
'Learn more: https://nextjs.org/docs/messages/ppr-caught-error'
)
)
}
if (isDynamicPostponeReason(createPostponeReason('%%%', '^^^')) === false) {
throw new Error(
'Invariant: isDynamicPostpone misidentified a postpone reason. This is a bug in Next.js'
)
}
const NEXT_PRERENDER_INTERRUPTED = 'NEXT_PRERENDER_INTERRUPTED' const NEXT_PRERENDER_INTERRUPTED = 'NEXT_PRERENDER_INTERRUPTED'
function createPrerenderInterruptedError(message: string): Error { function createPrerenderInterruptedError(message: string): Error {
...@@ -487,14 +405,6 @@ export function formatDynamicAPIAccesses( ...@@ -487,14 +405,6 @@ export function formatDynamicAPIAccesses(
}) })
} }
function assertPostpone() {
if (!hasPostpone) {
throw new Error(
`Invariant: React.unstable_postpone is not defined. This suggests the wrong version of React was loaded. This is a bug in Next.js`
)
}
}
/** /**
* This is a bit of a hack to allow us to abort a render using a Postpone instance instead of an Error which changes React's * This is a bit of a hack to allow us to abort a render using a Postpone instance instead of an Error which changes React's
* abort semantics slightly. * abort semantics slightly.
...@@ -550,7 +460,6 @@ export function createHangingInputAbortSignal( ...@@ -550,7 +460,6 @@ export function createHangingInputAbortSignal(
return controller.signal return controller.signal
case 'prerender-client': case 'prerender-client':
case 'prerender-ppr':
case 'prerender-legacy': case 'prerender-legacy':
case 'request': case 'request':
case 'cache': case 'cache':
...@@ -600,17 +509,6 @@ export function useDynamicRouteParams(expression: string) { ...@@ -600,17 +509,6 @@ export function useDynamicRouteParams(expression: string) {
} }
break break
} }
case 'prerender-ppr': {
const fallbackParams = workUnitStore.fallbackRouteParams
if (fallbackParams && fallbackParams.size > 0) {
return postponeWithTracking(
workStore.route,
expression,
workUnitStore.dynamicTracking
)
}
break
}
case 'prerender-runtime': case 'prerender-runtime':
throw new InvariantError( throw new InvariantError(
`\`${expression}\` was called during a runtime prerender. Next.js should be preventing ${expression} from being included in server components statically, but did not in this case.` `\`${expression}\` was called during a runtime prerender. Next.js should be preventing ${expression} from being included in server components statically, but did not in this case.`
...@@ -654,8 +552,7 @@ export function useDynamicSearchParams(expression: string) { ...@@ -654,8 +552,7 @@ export function useDynamicSearchParams(expression: string) {
) )
break break
} }
case 'prerender-legacy': case 'prerender-legacy': {
case 'prerender-ppr': {
if (workStore.forceStatic) { if (workStore.forceStatic) {
return return
} }
......
...@@ -276,7 +276,6 @@ export async function decryptActionBoundArgs( ...@@ -276,7 +276,6 @@ export async function decryptActionBoundArgs(
} }
break break
case 'prerender-client': case 'prerender-client':
case 'prerender-ppr':
case 'prerender-legacy': case 'prerender-legacy':
case 'request': case 'request':
case 'cache': case 'cache':
......
...@@ -35,7 +35,6 @@ export { createMetadataComponents } from '../../lib/metadata/metadata' ...@@ -35,7 +35,6 @@ export { createMetadataComponents } from '../../lib/metadata/metadata'
export { RootLayoutBoundary } from '../../lib/framework/boundary-components' export { RootLayoutBoundary } from '../../lib/framework/boundary-components'
export { preloadStyle, preloadFont, preconnect } from './rsc/preloads' export { preloadStyle, preloadFont, preconnect } from './rsc/preloads'
export { Postpone } from './rsc/postpone'
export { taintObjectReference } from './rsc/taint' export { taintObjectReference } from './rsc/taint'
export { collectSegmentData } from './collect-segment-data' export { collectSegmentData } from './collect-segment-data'
......
/*
Files in the rsc directory are meant to be packaged as part of the RSC graph using next-app-loader.
*/
// When postpone is available in canary React we can switch to importing it directly
export { Postpone } from '../dynamic-rendering'
...@@ -123,7 +123,6 @@ export function getFlightStream<T>( ...@@ -123,7 +123,6 @@ export function getFlightStream<T>(
return responseOnNextTick return responseOnNextTick
case 'prerender': case 'prerender':
case 'prerender-runtime': case 'prerender-runtime':
case 'prerender-ppr':
case 'prerender-legacy': case 'prerender-legacy':
case 'request': case 'request':
case 'cache': case 'cache':
......
...@@ -225,25 +225,6 @@ interface StaticPrerenderStoreCommon { ...@@ -225,25 +225,6 @@ interface StaticPrerenderStoreCommon {
readonly allowEmptyStaticShell: boolean readonly allowEmptyStaticShell: boolean
} }
export interface PrerenderStorePPR
extends CommonWorkUnitStore,
RevalidateStore {
readonly type: 'prerender-ppr'
readonly rootParams: Params
readonly dynamicTracking: null | DynamicTrackingState
/**
* The set of unknown route parameters. Accessing these will be tracked as
* a dynamic access.
*/
readonly fallbackRouteParams: OpaqueFallbackRouteParams | null
/**
* The resume data cache for this prerender.
*/
prerenderResumeDataCache: PrerenderResumeDataCache
}
export interface PrerenderStoreLegacy export interface PrerenderStoreLegacy
extends CommonWorkUnitStore, extends CommonWorkUnitStore,
RevalidateStore { RevalidateStore {
...@@ -251,10 +232,7 @@ export interface PrerenderStoreLegacy ...@@ -251,10 +232,7 @@ export interface PrerenderStoreLegacy
readonly rootParams: Params readonly rootParams: Params
} }
export type PrerenderStore = export type PrerenderStore = PrerenderStoreLegacy | PrerenderStoreModern
| PrerenderStoreLegacy
| PrerenderStorePPR
| PrerenderStoreModern
// /** Like `PrerenderStoreModern`, but only including static prerenders (i.e. not runtime prerenders) */ // /** Like `PrerenderStoreModern`, but only including static prerenders (i.e. not runtime prerenders) */
export type StaticPrerenderStore = Exclude< export type StaticPrerenderStore = Exclude<
...@@ -355,7 +333,6 @@ export function getPrerenderResumeDataCache( ...@@ -355,7 +333,6 @@ export function getPrerenderResumeDataCache(
switch (workUnitStore.type) { switch (workUnitStore.type) {
case 'prerender': case 'prerender':
case 'prerender-runtime': case 'prerender-runtime':
case 'prerender-ppr':
return workUnitStore.prerenderResumeDataCache return workUnitStore.prerenderResumeDataCache
case 'prerender-client': case 'prerender-client':
// TODO eliminate fetch caching in client scope and stop exposing this data // TODO eliminate fetch caching in client scope and stop exposing this data
...@@ -391,10 +368,8 @@ export function getRenderResumeDataCache( ...@@ -391,10 +368,8 @@ export function getRenderResumeDataCache(
// that is used to read from prefilled caches. // that is used to read from prefilled caches.
return workUnitStore.renderResumeDataCache return workUnitStore.renderResumeDataCache
} }
// fallthrough // Otherwise we return the mutable prerender resume data cache here as an
case 'prerender-ppr': // immutable version of the cache as it can also be used for reading.
// Otherwise we return the mutable resume data cache here as an immutable
// version of the cache as it can also be used for reading.
return workUnitStore.prerenderResumeDataCache ?? null return workUnitStore.prerenderResumeDataCache ?? null
case 'cache': case 'cache':
case 'private-cache': case 'private-cache':
...@@ -420,7 +395,6 @@ export function getHmrRefreshHash( ...@@ -420,7 +395,6 @@ export function getHmrRefreshHash(
case 'request': case 'request':
return workUnitStore.cookies.get(NEXT_HMR_REFRESH_HASH_COOKIE)?.value return workUnitStore.cookies.get(NEXT_HMR_REFRESH_HASH_COOKIE)?.value
case 'prerender-client': case 'prerender-client':
case 'prerender-ppr':
case 'prerender-legacy': case 'prerender-legacy':
case 'unstable-cache': case 'unstable-cache':
break break
...@@ -445,7 +419,6 @@ export function isHmrRefresh( ...@@ -445,7 +419,6 @@ export function isHmrRefresh(
case 'prerender': case 'prerender':
case 'prerender-client': case 'prerender-client':
case 'prerender-runtime': case 'prerender-runtime':
case 'prerender-ppr':
case 'prerender-legacy': case 'prerender-legacy':
case 'unstable-cache': case 'unstable-cache':
break break
...@@ -470,7 +443,6 @@ export function getServerComponentsHmrCache( ...@@ -470,7 +443,6 @@ export function getServerComponentsHmrCache(
case 'prerender': case 'prerender':
case 'prerender-client': case 'prerender-client':
case 'prerender-runtime': case 'prerender-runtime':
case 'prerender-ppr':
case 'prerender-legacy': case 'prerender-legacy':
case 'unstable-cache': case 'unstable-cache':
break break
...@@ -499,7 +471,6 @@ export function getDraftModeProviderForCacheScope( ...@@ -499,7 +471,6 @@ export function getDraftModeProviderForCacheScope(
return workUnitStore.draftMode return workUnitStore.draftMode
case 'prerender': case 'prerender':
case 'prerender-client': case 'prerender-client':
case 'prerender-ppr':
case 'prerender-legacy': case 'prerender-legacy':
break break
default: default:
...@@ -525,7 +496,6 @@ export function getCacheSignal( ...@@ -525,7 +496,6 @@ export function getCacheSignal(
} }
// fallthrough // fallthrough
} }
case 'prerender-ppr':
case 'prerender-legacy': case 'prerender-legacy':
case 'cache': case 'cache':
case 'private-cache': case 'private-cache':
...@@ -545,7 +515,6 @@ export function getRuntimeStagePromise( ...@@ -545,7 +515,6 @@ export function getRuntimeStagePromise(
return workUnitStore.runtimeStagePromise return workUnitStore.runtimeStagePromise
case 'prerender': case 'prerender':
case 'prerender-client': case 'prerender-client':
case 'prerender-ppr':
case 'prerender-legacy': case 'prerender-legacy':
case 'request': case 'request':
case 'cache': case 'cache':
......
...@@ -134,7 +134,6 @@ import { toRoute } from './lib/to-route' ...@@ -134,7 +134,6 @@ import { toRoute } from './lib/to-route'
import type { DeepReadonly } from '../shared/lib/deep-readonly' import type { DeepReadonly } from '../shared/lib/deep-readonly'
import { isNodeNextRequest, isNodeNextResponse } from './base-http/helpers' import { isNodeNextRequest, isNodeNextResponse } from './base-http/helpers'
import { patchSetHeaderWithCookieSupport } from './lib/patch-set-header' import { patchSetHeaderWithCookieSupport } from './lib/patch-set-header'
import { checkIsAppPPREnabled } from './lib/experimental/ppr'
import { import {
getBuiltinRequestContext, getBuiltinRequestContext,
type WaitUntil, type WaitUntil,
...@@ -423,7 +422,7 @@ export default abstract class Server< ...@@ -423,7 +422,7 @@ export default abstract class Server<
readonly data: NextDataPathnameNormalizer | undefined readonly data: NextDataPathnameNormalizer | undefined
} }
private readonly isAppPPREnabled: boolean private readonly isCacheComponentsEnabled: boolean
/** /**
* This is used to persist cache scopes across * This is used to persist cache scopes across
...@@ -505,9 +504,8 @@ export default abstract class Server< ...@@ -505,9 +504,8 @@ export default abstract class Server<
this.enabledDirectories = this.getEnabledDirectories(dev) this.enabledDirectories = this.getEnabledDirectories(dev)
this.isAppPPREnabled = this.isCacheComponentsEnabled =
this.enabledDirectories.app && this.enabledDirectories.app && !!this.nextConfig.cacheComponents
checkIsAppPPREnabled(this.nextConfig.experimental.ppr)
this.normalizers = { this.normalizers = {
// We should normalize the pathname from the RSC prefix only in minimal // We should normalize the pathname from the RSC prefix only in minimal
...@@ -1056,7 +1054,7 @@ export default abstract class Server< ...@@ -1056,7 +1054,7 @@ export default abstract class Server<
// It's important to execute the following block even it the request // It's important to execute the following block even it the request
// matches a pages data route from above. // matches a pages data route from above.
if ( if (
this.isAppPPREnabled && this.isCacheComponentsEnabled &&
this.minimalMode && this.minimalMode &&
req.headers[NEXT_RESUME_HEADER] === '1' && req.headers[NEXT_RESUME_HEADER] === '1' &&
req.method === 'POST' req.method === 'POST'
...@@ -2177,7 +2175,7 @@ export default abstract class Server< ...@@ -2177,7 +2175,7 @@ export default abstract class Server<
* enabled, then the given route _could_ support PPR. * enabled, then the given route _could_ support PPR.
*/ */
const couldSupportPPR: boolean = const couldSupportPPR: boolean =
this.isAppPPREnabled && this.isCacheComponentsEnabled &&
typeof routeModule !== 'undefined' && typeof routeModule !== 'undefined' &&
isAppPageRouteModule(routeModule) isAppPageRouteModule(routeModule)
......
...@@ -11,7 +11,10 @@ import type { WEB_VITALS } from '../shared/lib/utils' ...@@ -11,7 +11,10 @@ import type { WEB_VITALS } from '../shared/lib/utils'
import type { NextParsedUrlQuery } from './request-meta' import type { NextParsedUrlQuery } from './request-meta'
import type { SizeLimit } from '../types' import type { SizeLimit } from '../types'
import type { SupportedTestRunners } from '../cli/next-test' import type { SupportedTestRunners } from '../cli/next-test'
import type { ExperimentalPPRConfig } from './lib/experimental/ppr' /**
* @deprecated This type is only kept for backwards compatibility with the deprecated `experimental.ppr` config option.
*/
export type ExperimentalPPRConfig = boolean | 'incremental'
import { INFINITE_CACHE } from '../lib/constants' import { INFINITE_CACHE } from '../lib/constants'
import { isStableBuild } from '../shared/lib/errors/canary-only-config-error' import { isStableBuild } from '../shared/lib/errors/canary-only-config-error'
import type { FallbackRouteParam } from '../build/static-paths/types' import type { FallbackRouteParam } from '../build/static-paths/types'
......
...@@ -1350,9 +1350,6 @@ function assignDefaultsAndValidate( ...@@ -1350,9 +1350,6 @@ function assignDefaultsAndValidate(
} }
if (result.cacheComponents) { if (result.cacheComponents) {
// TODO: remove once we've finished migrating internally to cacheComponents.
result.experimental.ppr = true
// Prerender sourcemaps are enabled by default when using cacheComponents, unless explicitly disabled. // Prerender sourcemaps are enabled by default when using cacheComponents, unless explicitly disabled.
if (result.enablePrerenderSourceMaps === undefined) { if (result.enablePrerenderSourceMaps === undefined) {
result.enablePrerenderSourceMaps = true result.enablePrerenderSourceMaps = true
......
...@@ -778,7 +778,6 @@ export default class DevServer extends Server { ...@@ -778,7 +778,6 @@ export default class DevServer extends Server {
distDir: this.distDir, distDir: this.distDir,
pathname, pathname,
config: { config: {
pprConfig: this.nextConfig.experimental.ppr,
configFileName, configFileName,
cacheComponents: Boolean(this.nextConfig.cacheComponents), cacheComponents: Boolean(this.nextConfig.cacheComponents),
}, },
......
...@@ -17,10 +17,6 @@ import { loadComponents } from '../load-components' ...@@ -17,10 +17,6 @@ import { loadComponents } from '../load-components'
import { setHttpClientAndAgentOptions } from '../setup-http-agent-env' import { setHttpClientAndAgentOptions } from '../setup-http-agent-env'
import type { IncrementalCache } from '../lib/incremental-cache' import type { IncrementalCache } from '../lib/incremental-cache'
import { isAppPageRouteModule } from '../route-modules/checks' import { isAppPageRouteModule } from '../route-modules/checks'
import {
checkIsRoutePPREnabled,
type ExperimentalPPRConfig,
} from '../lib/experimental/ppr'
import { InvariantError } from '../../shared/lib/invariant-error' import { InvariantError } from '../../shared/lib/invariant-error'
import { collectRootParamKeys } from '../../build/segment-config/app/collect-root-param-keys' import { collectRootParamKeys } from '../../build/segment-config/app/collect-root-param-keys'
import { buildAppStaticPaths } from '../../build/static-paths/app' import { buildAppStaticPaths } from '../../build/static-paths/app'
...@@ -29,7 +25,6 @@ import { createIncrementalCache } from '../../export/helpers/create-incremental- ...@@ -29,7 +25,6 @@ import { createIncrementalCache } from '../../export/helpers/create-incremental-
import { parseAppRoute } from '../../shared/lib/router/routes/app' import { parseAppRoute } from '../../shared/lib/router/routes/app'
type RuntimeConfig = { type RuntimeConfig = {
pprConfig: ExperimentalPPRConfig | undefined
configFileName: string configFileName: string
cacheComponents: boolean cacheComponents: boolean
} }
...@@ -126,8 +121,7 @@ export async function loadStaticPaths({ ...@@ -126,8 +121,7 @@ export async function loadStaticPaths({
} }
const isRoutePPREnabled = const isRoutePPREnabled =
isAppPageRouteModule(routeModule) && isAppPageRouteModule(routeModule) && config.cacheComponents
checkIsRoutePPREnabled(config.pprConfig)
const rootParamKeys = collectRootParamKeys(routeModule) const rootParamKeys = collectRootParamKeys(routeModule)
......
/**
* If set to `incremental`, only those leaf pages that export
* `experimental_ppr = true` will have partial prerendering enabled. If any
* page exports this value as `false` or does not export it at all will not
* have partial prerendering enabled. If set to a boolean, the options for
* `experimental_ppr` will be ignored.
*/
export type ExperimentalPPRConfig = boolean | 'incremental'
/**
* Returns true if partial prerendering is enabled for the application. It does
* not tell you if a given route has PPR enabled, as that requires analysis of
* the route's configuration.
*
* @see {@link checkIsRoutePPREnabled} - for checking if a specific route has PPR enabled.
*/
export function checkIsAppPPREnabled(
config: ExperimentalPPRConfig | undefined
): boolean {
// If the config is undefined, partial prerendering is disabled.
if (typeof config === 'undefined') return false
// If the config is a boolean, use it directly.
if (typeof config === 'boolean') return config
// If the config is a string, it must be 'incremental' to enable partial
// prerendering.
if (config === 'incremental') return true
return false
}
/**
* Returns true if partial prerendering is supported for the current page with
* the provided app configuration. If the application doesn't have partial
* prerendering enabled, this function will always return false. If you want to
* check if the application has partial prerendering enabled
*
* @see {@link checkIsAppPPREnabled} for checking if the application has PPR enabled.
*/
export function checkIsRoutePPREnabled(
config: ExperimentalPPRConfig | undefined
): boolean {
// If the config is undefined, partial prerendering is disabled.
if (typeof config === 'undefined') return false
// If the config is a boolean, use it directly.
if (typeof config === 'boolean') return config
return false
}
...@@ -358,7 +358,6 @@ export function createPatchedFetcher( ...@@ -358,7 +358,6 @@ export function createPatchedFetcher(
case 'prerender-runtime': case 'prerender-runtime':
// TODO: Stop accumulating tags in client prerender. (fallthrough) // TODO: Stop accumulating tags in client prerender. (fallthrough)
case 'prerender-client': case 'prerender-client':
case 'prerender-ppr':
case 'prerender-legacy': case 'prerender-legacy':
case 'cache': case 'cache':
case 'private-cache': case 'private-cache':
...@@ -399,7 +398,6 @@ export function createPatchedFetcher( ...@@ -399,7 +398,6 @@ export function createPatchedFetcher(
case 'prerender': case 'prerender':
case 'prerender-client': case 'prerender-client':
case 'prerender-runtime': case 'prerender-runtime':
case 'prerender-ppr':
case 'prerender-legacy': case 'prerender-legacy':
case 'request': case 'request':
case 'cache': case 'cache':
...@@ -568,7 +566,6 @@ export function createPatchedFetcher( ...@@ -568,7 +566,6 @@ export function createPatchedFetcher(
) )
} }
break break
case 'prerender-ppr':
case 'prerender-legacy': case 'prerender-legacy':
case 'cache': case 'cache':
case 'private-cache': case 'private-cache':
...@@ -694,7 +691,6 @@ export function createPatchedFetcher( ...@@ -694,7 +691,6 @@ export function createPatchedFetcher(
) )
} }
break break
case 'prerender-ppr':
case 'prerender-legacy': case 'prerender-legacy':
case 'cache': case 'cache':
case 'private-cache': case 'private-cache':
...@@ -739,7 +735,6 @@ export function createPatchedFetcher( ...@@ -739,7 +735,6 @@ export function createPatchedFetcher(
case 'prerender': case 'prerender':
case 'prerender-client': case 'prerender-client':
case 'prerender-runtime': case 'prerender-runtime':
case 'prerender-ppr':
case 'prerender-legacy': case 'prerender-legacy':
case 'unstable-cache': case 'unstable-cache':
break break
...@@ -885,7 +880,6 @@ export function createPatchedFetcher( ...@@ -885,7 +880,6 @@ export function createPatchedFetcher(
) )
} }
// fallthrough // fallthrough
case 'prerender-ppr':
case 'prerender-legacy': case 'prerender-legacy':
case 'cache': case 'cache':
case 'private-cache': case 'private-cache':
...@@ -966,7 +960,6 @@ export function createPatchedFetcher( ...@@ -966,7 +960,6 @@ export function createPatchedFetcher(
) )
} }
break break
case 'prerender-ppr':
case 'prerender-legacy': case 'prerender-legacy':
case 'cache': case 'cache':
case 'private-cache': case 'private-cache':
...@@ -1094,7 +1087,6 @@ export function createPatchedFetcher( ...@@ -1094,7 +1087,6 @@ export function createPatchedFetcher(
) )
} }
break break
case 'prerender-ppr':
case 'prerender-legacy': case 'prerender-legacy':
case 'cache': case 'cache':
case 'private-cache': case 'private-cache':
...@@ -1144,7 +1136,6 @@ export function createPatchedFetcher( ...@@ -1144,7 +1136,6 @@ export function createPatchedFetcher(
case 'private-cache': case 'private-cache':
case 'unstable-cache': case 'unstable-cache':
case 'prerender-legacy': case 'prerender-legacy':
case 'prerender-ppr':
break break
default: default:
workUnitStore satisfies never workUnitStore satisfies never
......
...@@ -244,7 +244,6 @@ function patchConsoleMethod(methodName: InterceptableConsoleMethod): void { ...@@ -244,7 +244,6 @@ function patchConsoleMethod(methodName: InterceptableConsoleMethod): void {
} }
// intentional fallthrough // intentional fallthrough
case 'prerender-legacy': case 'prerender-legacy':
case 'prerender-ppr':
case 'cache': case 'cache':
case 'unstable-cache': case 'unstable-cache':
case 'private-cache': case 'private-cache':
......
...@@ -599,7 +599,6 @@ function filteringUnhandledRejectionHandler( ...@@ -599,7 +599,6 @@ function filteringUnhandledRejectionHandler(
} }
break break
} }
case 'prerender-ppr':
case 'prerender-legacy': case 'prerender-legacy':
case 'request': case 'request':
case 'cache': case 'cache':
......
...@@ -142,7 +142,6 @@ export function io(expression: string, type: ApiType) { ...@@ -142,7 +142,6 @@ export function io(expression: string, type: ApiType) {
} }
} }
break break
case 'prerender-ppr':
case 'prerender-legacy': case 'prerender-legacy':
case 'cache': case 'cache':
case 'private-cache': case 'private-cache':
......
...@@ -4,7 +4,6 @@ import { ...@@ -4,7 +4,6 @@ import {
workUnitAsyncStorage, workUnitAsyncStorage,
} from '../app-render/work-unit-async-storage.external' } from '../app-render/work-unit-async-storage.external'
import { import {
postponeWithTracking,
throwToInterruptStaticGeneration, throwToInterruptStaticGeneration,
trackDynamicDataInDynamicRender, trackDynamicDataInDynamicRender,
} from '../app-render/dynamic-rendering' } from '../app-render/dynamic-rendering'
...@@ -84,14 +83,6 @@ export function connection(): Promise<void> { ...@@ -84,14 +83,6 @@ export function connection(): Promise<void> {
workStore.route, workStore.route,
'`connection()`' '`connection()`'
) )
case 'prerender-ppr':
// We use React's postpone API to interrupt rendering here to create a
// dynamic hole
return postponeWithTracking(
workStore.route,
'connection',
workUnitStore.dynamicTracking
)
case 'prerender-legacy': case 'prerender-legacy':
// We throw an error here to interrupt prerendering to mark the route // We throw an error here to interrupt prerendering to mark the route
// as dynamic // as dynamic
......
...@@ -16,7 +16,6 @@ import { ...@@ -16,7 +16,6 @@ import {
} from '../app-render/work-unit-async-storage.external' } from '../app-render/work-unit-async-storage.external'
import { import {
delayUntilRuntimeStage, delayUntilRuntimeStage,
postponeWithTracking,
throwToInterruptStaticGeneration, throwToInterruptStaticGeneration,
trackDynamicDataInDynamicRender, trackDynamicDataInDynamicRender,
} from '../app-render/dynamic-rendering' } from '../app-render/dynamic-rendering'
...@@ -80,14 +79,6 @@ export function cookies(): Promise<ReadonlyRequestCookies> { ...@@ -80,14 +79,6 @@ export function cookies(): Promise<ReadonlyRequestCookies> {
throw new InvariantError( throw new InvariantError(
`${exportName} must not be used within a Client Component. Next.js should be preventing ${exportName} from being included in Client Components statically, but did not in this case.` `${exportName} must not be used within a Client Component. Next.js should be preventing ${exportName} from being included in Client Components statically, but did not in this case.`
) )
case 'prerender-ppr':
// We need track dynamic access here eagerly to keep continuity with
// how cookies has worked in PPR without cacheComponents.
return postponeWithTracking(
workStore.route,
callingExpression,
workUnitStore.dynamicTracking
)
case 'prerender-legacy': case 'prerender-legacy':
// We track dynamic access here so we don't need to wrap the cookies // We track dynamic access here so we don't need to wrap the cookies
// in individual property access tracking. // in individual property access tracking.
......
...@@ -13,7 +13,6 @@ import { workUnitAsyncStorage } from '../app-render/work-unit-async-storage.exte ...@@ -13,7 +13,6 @@ import { workUnitAsyncStorage } from '../app-render/work-unit-async-storage.exte
import { import {
abortAndThrowOnSynchronousRequestDataAccess, abortAndThrowOnSynchronousRequestDataAccess,
delayUntilRuntimeStage, delayUntilRuntimeStage,
postponeWithTracking,
trackDynamicDataInDynamicRender, trackDynamicDataInDynamicRender,
} from '../app-render/dynamic-rendering' } from '../app-render/dynamic-rendering'
import { createDedupedByCallsiteServerErrorLoggerDev } from '../create-deduped-by-callsite-server-error-logger' import { createDedupedByCallsiteServerErrorLoggerDev } from '../create-deduped-by-callsite-server-error-logger'
...@@ -60,7 +59,6 @@ export function draftMode(): Promise<DraftMode> { ...@@ -60,7 +59,6 @@ export function draftMode(): Promise<DraftMode> {
// eslint-disable-next-line no-fallthrough // eslint-disable-next-line no-fallthrough
case 'prerender': case 'prerender':
case 'prerender-client': case 'prerender-client':
case 'prerender-ppr':
case 'prerender-legacy': case 'prerender-legacy':
// Return empty draft mode // Return empty draft mode
return createOrGetCachedDraftMode(null, workStore) return createOrGetCachedDraftMode(null, workStore)
...@@ -221,12 +219,6 @@ function trackDynamicDraftMode(expression: string, constructorOpt: Function) { ...@@ -221,12 +219,6 @@ function trackDynamicDraftMode(expression: string, constructorOpt: Function) {
throw new InvariantError( throw new InvariantError(
`${exportName} must not be used within a Client Component. Next.js should be preventing ${exportName} from being included in Client Components statically, but did not in this case.` `${exportName} must not be used within a Client Component. Next.js should be preventing ${exportName} from being included in Client Components statically, but did not in this case.`
) )
case 'prerender-ppr':
return postponeWithTracking(
workStore.route,
expression,
workUnitStore.dynamicTracking
)
case 'prerender-legacy': case 'prerender-legacy':
workUnitStore.revalidate = 0 workUnitStore.revalidate = 0
......
...@@ -14,7 +14,6 @@ import { ...@@ -14,7 +14,6 @@ import {
} from '../app-render/work-unit-async-storage.external' } from '../app-render/work-unit-async-storage.external'
import { import {
delayUntilRuntimeStage, delayUntilRuntimeStage,
postponeWithTracking,
throwToInterruptStaticGeneration, throwToInterruptStaticGeneration,
trackDynamicDataInDynamicRender, trackDynamicDataInDynamicRender,
} from '../app-render/dynamic-rendering' } from '../app-render/dynamic-rendering'
...@@ -78,7 +77,6 @@ export function headers(): Promise<ReadonlyHeaders> { ...@@ -78,7 +77,6 @@ export function headers(): Promise<ReadonlyHeaders> {
case 'prerender-client': case 'prerender-client':
case 'private-cache': case 'private-cache':
case 'prerender-runtime': case 'prerender-runtime':
case 'prerender-ppr':
case 'prerender-legacy': case 'prerender-legacy':
case 'request': case 'request':
break break
...@@ -102,16 +100,6 @@ export function headers(): Promise<ReadonlyHeaders> { ...@@ -102,16 +100,6 @@ export function headers(): Promise<ReadonlyHeaders> {
throw new InvariantError( throw new InvariantError(
`${exportName} must not be used within a client component. Next.js should be preventing ${exportName} from being included in client components statically, but did not in this case.` `${exportName} must not be used within a client component. Next.js should be preventing ${exportName} from being included in client components statically, but did not in this case.`
) )
case 'prerender-ppr':
// PPR Prerender (no cacheComponents)
// We are prerendering with PPR. We need track dynamic access here eagerly
// to keep continuity with how headers has worked in PPR without cacheComponents.
// TODO consider switching the semantic to throw on property access instead
return postponeWithTracking(
workStore.route,
callingExpression,
workUnitStore.dynamicTracking
)
case 'prerender-legacy': case 'prerender-legacy':
// Legacy Prerender // Legacy Prerender
// We are in a legacy static generation mode while prerendering // We are in a legacy static generation mode while prerendering
......
...@@ -5,16 +5,10 @@ import { ...@@ -5,16 +5,10 @@ import {
import type { OpaqueFallbackRouteParams } from './fallback-params' import type { OpaqueFallbackRouteParams } from './fallback-params'
import { ReflectAdapter } from '../web/spec-extension/adapters/reflect' import { ReflectAdapter } from '../web/spec-extension/adapters/reflect'
import { import { delayUntilRuntimeStage } from '../app-render/dynamic-rendering'
throwToInterruptStaticGeneration,
postponeWithTracking,
delayUntilRuntimeStage,
} from '../app-render/dynamic-rendering'
import { import {
workUnitAsyncStorage, workUnitAsyncStorage,
type PrerenderStorePPR,
type PrerenderStoreLegacy,
type StaticPrerenderStoreModern, type StaticPrerenderStoreModern,
type StaticPrerenderStore, type StaticPrerenderStore,
throwInvariantForMissingStore, throwInvariantForMissingStore,
...@@ -46,7 +40,6 @@ export function createParamsFromClient( ...@@ -46,7 +40,6 @@ export function createParamsFromClient(
switch (workUnitStore.type) { switch (workUnitStore.type) {
case 'prerender': case 'prerender':
case 'prerender-client': case 'prerender-client':
case 'prerender-ppr':
case 'prerender-legacy': case 'prerender-legacy':
return createStaticPrerenderParams( return createStaticPrerenderParams(
underlyingParams, underlyingParams,
...@@ -99,7 +92,6 @@ export function createServerParamsForRoute( ...@@ -99,7 +92,6 @@ export function createServerParamsForRoute(
switch (workUnitStore.type) { switch (workUnitStore.type) {
case 'prerender': case 'prerender':
case 'prerender-client': case 'prerender-client':
case 'prerender-ppr':
case 'prerender-legacy': case 'prerender-legacy':
return createStaticPrerenderParams( return createStaticPrerenderParams(
underlyingParams, underlyingParams,
...@@ -145,7 +137,6 @@ export function createServerParamsForServerSegment( ...@@ -145,7 +137,6 @@ export function createServerParamsForServerSegment(
switch (workUnitStore.type) { switch (workUnitStore.type) {
case 'prerender': case 'prerender':
case 'prerender-client': case 'prerender-client':
case 'prerender-ppr':
case 'prerender-legacy': case 'prerender-legacy':
return createStaticPrerenderParams( return createStaticPrerenderParams(
underlyingParams, underlyingParams,
...@@ -220,7 +211,6 @@ export function createPrerenderParamsForClientSegment( ...@@ -220,7 +211,6 @@ export function createPrerenderParamsForClientSegment(
throw new InvariantError( throw new InvariantError(
'createPrerenderParamsForClientSegment should not be called in cache contexts.' 'createPrerenderParamsForClientSegment should not be called in cache contexts.'
) )
case 'prerender-ppr':
case 'prerender-legacy': case 'prerender-legacy':
case 'prerender-runtime': case 'prerender-runtime':
case 'request': case 'request':
...@@ -261,22 +251,6 @@ function createStaticPrerenderParams( ...@@ -261,22 +251,6 @@ function createStaticPrerenderParams(
} }
break break
} }
case 'prerender-ppr': {
const fallbackParams = prerenderStore.fallbackRouteParams
if (fallbackParams) {
for (const key in underlyingParams) {
if (fallbackParams.has(key)) {
return makeErroringParams(
underlyingParams,
fallbackParams,
workStore,
prerenderStore
)
}
}
}
break
}
case 'prerender-legacy': case 'prerender-legacy':
break break
default: default:
...@@ -378,65 +352,6 @@ function makeHangingParams( ...@@ -378,65 +352,6 @@ function makeHangingParams(
return promise return promise
} }
function makeErroringParams(
underlyingParams: Params,
fallbackParams: OpaqueFallbackRouteParams,
workStore: WorkStore,
prerenderStore: PrerenderStorePPR | PrerenderStoreLegacy
): Promise<Params> {
const cachedParams = CachedParams.get(underlyingParams)
if (cachedParams) {
return cachedParams
}
const augmentedUnderlying = { ...underlyingParams }
// We don't use makeResolvedReactPromise here because params
// supports copying with spread and we don't want to unnecessarily
// instrument the promise with spreadable properties of ReactPromise.
const promise = Promise.resolve(augmentedUnderlying)
CachedParams.set(underlyingParams, promise)
Object.keys(underlyingParams).forEach((prop) => {
if (wellKnownProperties.has(prop)) {
// These properties cannot be shadowed because they need to be the
// true underlying value for Promises to work correctly at runtime
} else {
if (fallbackParams.has(prop)) {
Object.defineProperty(augmentedUnderlying, prop, {
get() {
const expression = describeStringPropertyAccess('params', prop)
// In most dynamic APIs we also throw if `dynamic = "error"` however
// for params is only dynamic when we're generating a fallback shell
// and even when `dynamic = "error"` we still support generating dynamic
// fallback shells
// TODO remove this comment when cacheComponents is the default since there
// will be no `dynamic = "error"`
if (prerenderStore.type === 'prerender-ppr') {
// PPR Prerender (no cacheComponents)
postponeWithTracking(
workStore.route,
expression,
prerenderStore.dynamicTracking
)
} else {
// Legacy Prerender
throwToInterruptStaticGeneration(
expression,
workStore,
prerenderStore
)
}
},
enumerable: true,
})
}
}
})
return promise
}
function makeUntrackedParams(underlyingParams: Params): Promise<Params> { function makeUntrackedParams(underlyingParams: Params): Promise<Params> {
const cachedParams = CachedParams.get(underlyingParams) const cachedParams = CachedParams.get(underlyingParams)
if (cachedParams) { if (cachedParams) {
......
import type { WorkStore } from '../app-render/work-async-storage.external' import type { WorkStore } from '../app-render/work-async-storage.external'
import { import { delayUntilRuntimeStage } from '../app-render/dynamic-rendering'
delayUntilRuntimeStage,
postponeWithTracking,
type DynamicTrackingState,
} from '../app-render/dynamic-rendering'
import { import {
throwInvariantForMissingStore, throwInvariantForMissingStore,
...@@ -23,7 +19,6 @@ export function createServerPathnameForMetadata( ...@@ -23,7 +19,6 @@ export function createServerPathnameForMetadata(
switch (workUnitStore.type) { switch (workUnitStore.type) {
case 'prerender': case 'prerender':
case 'prerender-client': case 'prerender-client':
case 'prerender-ppr':
case 'prerender-legacy': { case 'prerender-legacy': {
return createPrerenderPathname( return createPrerenderPathname(
underlyingPathname, underlyingPathname,
...@@ -73,13 +68,6 @@ function createPrerenderPathname( ...@@ -73,13 +68,6 @@ function createPrerenderPathname(
} }
break break
} }
case 'prerender-ppr': {
const fallbackParams = prerenderStore.fallbackRouteParams
if (fallbackParams && fallbackParams.size > 0) {
return makeErroringPathname(workStore, prerenderStore.dynamicTracking)
}
break
}
case 'prerender-legacy': case 'prerender-legacy':
break break
default: default:
...@@ -90,41 +78,6 @@ function createPrerenderPathname( ...@@ -90,41 +78,6 @@ function createPrerenderPathname(
return Promise.resolve(underlyingPathname) return Promise.resolve(underlyingPathname)
} }
function makeErroringPathname<T>(
workStore: WorkStore,
dynamicTracking: null | DynamicTrackingState
): Promise<T> {
let reject: null | ((reason: unknown) => void) = null
const promise = new Promise<T>((_, re) => {
reject = re
})
const originalThen = promise.then.bind(promise)
// We instrument .then so that we can generate a tracking event only if you actually
// await this promise, not just that it is created.
promise.then = (onfulfilled, onrejected) => {
if (reject) {
try {
postponeWithTracking(
workStore.route,
'metadata relative url resolving',
dynamicTracking
)
} catch (error) {
reject(error)
reject = null
}
}
return originalThen(onfulfilled, onrejected)
}
// We wrap in a noop proxy to trick the runtime into thinking it
// isn't a native promise (it's not really). This is so that awaiting
// the promise will call the `then` property triggering the lazy postpone
return new Proxy(promise, {})
}
function createRenderPathname(underlyingPathname: string): Promise<string> { function createRenderPathname(underlyingPathname: string): Promise<string> {
return Promise.resolve(underlyingPathname) return Promise.resolve(underlyingPathname)
} }
import { InvariantError } from '../../shared/lib/invariant-error' import { InvariantError } from '../../shared/lib/invariant-error'
import {
postponeWithTracking,
throwToInterruptStaticGeneration,
} from '../app-render/dynamic-rendering'
import { import {
workAsyncStorage, workAsyncStorage,
type WorkStore, type WorkStore,
} from '../app-render/work-async-storage.external' } from '../app-render/work-async-storage.external'
import { import {
workUnitAsyncStorage, workUnitAsyncStorage,
type PrerenderStoreLegacy,
type PrerenderStorePPR,
type StaticPrerenderStore, type StaticPrerenderStore,
} from '../app-render/work-unit-async-storage.external' } from '../app-render/work-unit-async-storage.external'
import { makeHangingPromise } from '../dynamic-rendering-utils' import { makeHangingPromise } from '../dynamic-rendering-utils'
import type { ParamValue } from './params' import type { ParamValue } from './params'
import { describeStringPropertyAccess } from '../../shared/lib/utils/reflect-utils'
import { actionAsyncStorage } from '../app-render/action-async-storage.external' import { actionAsyncStorage } from '../app-render/action-async-storage.external'
/** /**
...@@ -65,7 +58,6 @@ export function getRootParam(paramName: string): Promise<ParamValue> { ...@@ -65,7 +58,6 @@ export function getRootParam(paramName: string): Promise<ParamValue> {
} }
case 'prerender': case 'prerender':
case 'prerender-client': case 'prerender-client':
case 'prerender-ppr':
case 'prerender-legacy': { case 'prerender-legacy': {
return createPrerenderRootParamPromise( return createPrerenderRootParamPromise(
paramName, paramName,
...@@ -100,7 +92,6 @@ function createPrerenderRootParamPromise( ...@@ -100,7 +92,6 @@ function createPrerenderRootParamPromise(
} }
case 'prerender': case 'prerender':
case 'prerender-legacy': case 'prerender-legacy':
case 'prerender-ppr':
default: default:
} }
...@@ -122,22 +113,6 @@ function createPrerenderRootParamPromise( ...@@ -122,22 +113,6 @@ function createPrerenderRootParamPromise(
} }
break break
} }
case 'prerender-ppr': {
// We aren't in a cacheComponents prerender, but the param is a fallback,
// so we need to make an erroring params object which will postpone/error if you access it
if (
prerenderStore.fallbackRouteParams &&
prerenderStore.fallbackRouteParams.has(paramName)
) {
return makeErroringRootParamPromise(
paramName,
workStore,
prerenderStore,
apiName
)
}
break
}
case 'prerender-legacy': { case 'prerender-legacy': {
// legacy prerenders can't have fallback params // legacy prerenders can't have fallback params
break break
...@@ -150,36 +125,3 @@ function createPrerenderRootParamPromise( ...@@ -150,36 +125,3 @@ function createPrerenderRootParamPromise(
// If the param is not a fallback param, we just return the statically available value. // If the param is not a fallback param, we just return the statically available value.
return Promise.resolve(underlyingParams[paramName]) return Promise.resolve(underlyingParams[paramName])
} }
/** Deliberately async -- we want to create a rejected promise, not error synchronously. */
async function makeErroringRootParamPromise(
paramName: string,
workStore: WorkStore,
prerenderStore: PrerenderStorePPR | PrerenderStoreLegacy,
apiName: string
): Promise<ParamValue> {
const expression = describeStringPropertyAccess(apiName, paramName)
// In most dynamic APIs, we also throw if `dynamic = "error"`.
// However, root params are only dynamic when we're generating a fallback shell,
// and even with `dynamic = "error"` we still support generating dynamic fallback shells.
// TODO: remove this comment when cacheComponents is the default since there will be no `dynamic = "error"`
switch (prerenderStore.type) {
case 'prerender-ppr': {
return postponeWithTracking(
workStore.route,
expression,
prerenderStore.dynamicTracking
)
}
case 'prerender-legacy': {
return throwToInterruptStaticGeneration(
expression,
workStore,
prerenderStore
)
}
default: {
prerenderStore satisfies never
}
}
}
...@@ -3,7 +3,6 @@ import type { WorkStore } from '../app-render/work-async-storage.external' ...@@ -3,7 +3,6 @@ import type { WorkStore } from '../app-render/work-async-storage.external'
import { ReflectAdapter } from '../web/spec-extension/adapters/reflect' import { ReflectAdapter } from '../web/spec-extension/adapters/reflect'
import { import {
throwToInterruptStaticGeneration, throwToInterruptStaticGeneration,
postponeWithTracking,
annotateDynamicAccess, annotateDynamicAccess,
delayUntilRuntimeStage, delayUntilRuntimeStage,
} from '../app-render/dynamic-rendering' } from '../app-render/dynamic-rendering'
...@@ -11,7 +10,6 @@ import { ...@@ -11,7 +10,6 @@ import {
import { import {
workUnitAsyncStorage, workUnitAsyncStorage,
type PrerenderStoreLegacy, type PrerenderStoreLegacy,
type PrerenderStorePPR,
type PrerenderStoreModern, type PrerenderStoreModern,
type PrerenderStoreModernRuntime, type PrerenderStoreModernRuntime,
type StaticPrerenderStore, type StaticPrerenderStore,
...@@ -46,7 +44,6 @@ export function createSearchParamsFromClient( ...@@ -46,7 +44,6 @@ export function createSearchParamsFromClient(
switch (workUnitStore.type) { switch (workUnitStore.type) {
case 'prerender': case 'prerender':
case 'prerender-client': case 'prerender-client':
case 'prerender-ppr':
case 'prerender-legacy': case 'prerender-legacy':
return createStaticPrerenderSearchParams(workStore, workUnitStore) return createStaticPrerenderSearchParams(workStore, workUnitStore)
case 'prerender-runtime': case 'prerender-runtime':
...@@ -85,7 +82,6 @@ export function createServerSearchParamsForServerPage( ...@@ -85,7 +82,6 @@ export function createServerSearchParamsForServerPage(
switch (workUnitStore.type) { switch (workUnitStore.type) {
case 'prerender': case 'prerender':
case 'prerender-client': case 'prerender-client':
case 'prerender-ppr':
case 'prerender-legacy': case 'prerender-legacy':
return createStaticPrerenderSearchParams(workStore, workUnitStore) return createStaticPrerenderSearchParams(workStore, workUnitStore)
case 'cache': case 'cache':
...@@ -143,7 +139,6 @@ export function createPrerenderSearchParamsForClientPage( ...@@ -143,7 +139,6 @@ export function createPrerenderSearchParamsForClientPage(
throw new InvariantError( throw new InvariantError(
'createPrerenderSearchParamsForClientPage should not be called in cache contexts.' 'createPrerenderSearchParamsForClientPage should not be called in cache contexts.'
) )
case 'prerender-ppr':
case 'prerender-legacy': case 'prerender-legacy':
case 'request': case 'request':
return Promise.resolve({}) return Promise.resolve({})
...@@ -169,7 +164,6 @@ function createStaticPrerenderSearchParams( ...@@ -169,7 +164,6 @@ function createStaticPrerenderSearchParams(
case 'prerender-client': case 'prerender-client':
// We are in a cacheComponents (PPR or otherwise) prerender // We are in a cacheComponents (PPR or otherwise) prerender
return makeHangingSearchParams(workStore, prerenderStore) return makeHangingSearchParams(workStore, prerenderStore)
case 'prerender-ppr':
case 'prerender-legacy': case 'prerender-legacy':
// We are in a legacy static generation and need to interrupt the // We are in a legacy static generation and need to interrupt the
// prerender when search params are accessed. // prerender when search params are accessed.
...@@ -273,7 +267,7 @@ function makeHangingSearchParams( ...@@ -273,7 +267,7 @@ function makeHangingSearchParams(
function makeErroringSearchParams( function makeErroringSearchParams(
workStore: WorkStore, workStore: WorkStore,
prerenderStore: PrerenderStoreLegacy | PrerenderStorePPR prerenderStore: PrerenderStoreLegacy
): Promise<SearchParams> { ): Promise<SearchParams> {
const cachedSearchParams = CachedSearchParams.get(workStore) const cachedSearchParams = CachedSearchParams.get(workStore)
if (cachedSearchParams) { if (cachedSearchParams) {
...@@ -303,13 +297,6 @@ function makeErroringSearchParams( ...@@ -303,13 +297,6 @@ function makeErroringSearchParams(
workStore.route, workStore.route,
expression expression
) )
} else if (prerenderStore.type === 'prerender-ppr') {
// PPR Prerender (no cacheComponents)
postponeWithTracking(
workStore.route,
expression,
prerenderStore.dynamicTracking
)
} else { } else {
// Legacy Prerender // Legacy Prerender
throwToInterruptStaticGeneration( throwToInterruptStaticGeneration(
......
...@@ -60,7 +60,6 @@ import { StaticGenBailoutError } from '../../../client/components/static-generat ...@@ -60,7 +60,6 @@ import { StaticGenBailoutError } from '../../../client/components/static-generat
import { isStaticGenEnabled } from './helpers/is-static-gen-enabled' import { isStaticGenEnabled } from './helpers/is-static-gen-enabled'
import { import {
abortAndThrowOnSynchronousRequestDataAccess, abortAndThrowOnSynchronousRequestDataAccess,
postponeWithTracking,
createDynamicTrackingState, createDynamicTrackingState,
getFirstDynamicReason, getFirstDynamicReason,
} from '../../app-render/dynamic-rendering' } from '../../app-render/dynamic-rendering'
...@@ -1209,12 +1208,6 @@ function trackDynamic( ...@@ -1209,12 +1208,6 @@ function trackDynamic(
throw new InvariantError( throw new InvariantError(
'A runtime prerender store should not be used for a route handler.' 'A runtime prerender store should not be used for a route handler.'
) )
case 'prerender-ppr':
return postponeWithTracking(
store.route,
expression,
workUnitStore.dynamicTracking
)
case 'prerender-legacy': case 'prerender-legacy':
workUnitStore.revalidate = 0 workUnitStore.revalidate = 0
......
...@@ -87,7 +87,6 @@ export function cacheLife(profile: CacheLifeProfiles | CacheLife): void { ...@@ -87,7 +87,6 @@ export function cacheLife(profile: CacheLifeProfiles | CacheLife): void {
case 'prerender': case 'prerender':
case 'prerender-client': case 'prerender-client':
case 'prerender-runtime': case 'prerender-runtime':
case 'prerender-ppr':
case 'prerender-legacy': case 'prerender-legacy':
case 'request': case 'request':
case 'unstable-cache': case 'unstable-cache':
......
...@@ -14,7 +14,6 @@ export function cacheTag(...tags: string[]): void { ...@@ -14,7 +14,6 @@ export function cacheTag(...tags: string[]): void {
case 'prerender': case 'prerender':
case 'prerender-client': case 'prerender-client':
case 'prerender-runtime': case 'prerender-runtime':
case 'prerender-ppr':
case 'prerender-legacy': case 'prerender-legacy':
case 'request': case 'request':
case 'unstable-cache': case 'unstable-cache':
......
...@@ -58,7 +58,6 @@ import { getCacheHandler } from './handlers' ...@@ -58,7 +58,6 @@ import { getCacheHandler } from './handlers'
import { UseCacheTimeoutError } from './use-cache-errors' import { UseCacheTimeoutError } from './use-cache-errors'
import { import {
createHangingInputAbortSignal, createHangingInputAbortSignal,
postponeWithTracking,
throwToInterruptStaticGeneration, throwToInterruptStaticGeneration,
} from '../app-render/dynamic-rendering' } from '../app-render/dynamic-rendering'
import { import {
...@@ -230,7 +229,6 @@ function createUseCacheStore( ...@@ -230,7 +229,6 @@ function createUseCacheStore(
break break
case 'prerender-runtime': case 'prerender-runtime':
case 'prerender': case 'prerender':
case 'prerender-ppr':
case 'prerender-legacy': case 'prerender-legacy':
case 'unstable-cache': case 'unstable-cache':
break break
...@@ -364,7 +362,6 @@ function propagateCacheLifeAndTags( ...@@ -364,7 +362,6 @@ function propagateCacheLifeAndTags(
case 'private-cache': case 'private-cache':
case 'prerender': case 'prerender':
case 'prerender-runtime': case 'prerender-runtime':
case 'prerender-ppr':
case 'prerender-legacy': case 'prerender-legacy':
propagateCacheLifeAndTagsToRevalidateStore( propagateCacheLifeAndTagsToRevalidateStore(
cacheContext.outerWorkUnitStore, cacheContext.outerWorkUnitStore,
...@@ -487,8 +484,7 @@ async function collectResult( ...@@ -487,8 +484,7 @@ async function collectResult(
case 'private-cache': case 'private-cache':
case 'cache': case 'cache':
case 'unstable-cache': case 'unstable-cache':
case 'prerender-legacy': case 'prerender-legacy': {
case 'prerender-ppr': {
propagateCacheLifeAndTags(cacheContext, entry) propagateCacheLifeAndTags(cacheContext, entry)
break break
} }
...@@ -564,7 +560,6 @@ async function generateCacheEntryImpl( ...@@ -564,7 +560,6 @@ async function generateCacheEntryImpl(
} }
}) })
break break
case 'prerender-ppr':
case 'prerender-legacy': case 'prerender-legacy':
case 'request': case 'request':
case 'cache': case 'cache':
...@@ -706,7 +701,6 @@ async function generateCacheEntryImpl( ...@@ -706,7 +701,6 @@ async function generateCacheEntryImpl(
await new Promise((resolve) => setTimeout(resolve)) await new Promise((resolve) => setTimeout(resolve))
} }
// fallthrough // fallthrough
case 'prerender-ppr':
case 'prerender-legacy': case 'prerender-legacy':
case 'cache': case 'cache':
case 'private-cache': case 'private-cache':
...@@ -887,12 +881,6 @@ export async function cache( ...@@ -887,12 +881,6 @@ export async function cache(
workStore.route, workStore.route,
expression expression
) )
case 'prerender-ppr':
return postponeWithTracking(
workStore.route,
expression,
workUnitStore.dynamicTracking
)
case 'prerender-legacy': case 'prerender-legacy':
return throwToInterruptStaticGeneration( return throwToInterruptStaticGeneration(
expression, expression,
...@@ -952,7 +940,6 @@ export async function cache( ...@@ -952,7 +940,6 @@ export async function cache(
) )
case 'prerender': case 'prerender':
case 'prerender-runtime': case 'prerender-runtime':
case 'prerender-ppr':
case 'prerender-legacy': case 'prerender-legacy':
case 'request': case 'request':
case 'cache': case 'cache':
...@@ -1198,7 +1185,6 @@ export async function cache( ...@@ -1198,7 +1185,6 @@ export async function cache(
break break
} }
// fallthrough // fallthrough
case 'prerender-ppr':
case 'prerender-legacy': case 'prerender-legacy':
case 'request': case 'request':
// TODO(restart-on-cache-miss): We need to handle params/searchParams on page components. // TODO(restart-on-cache-miss): We need to handle params/searchParams on page components.
...@@ -1301,7 +1287,6 @@ export async function cache( ...@@ -1301,7 +1287,6 @@ export async function cache(
} }
break break
} }
case 'prerender-ppr':
case 'prerender-legacy': case 'prerender-legacy':
case 'cache': case 'cache':
case 'private-cache': case 'private-cache':
...@@ -1350,7 +1335,6 @@ export async function cache( ...@@ -1350,7 +1335,6 @@ export async function cache(
break break
} }
case 'prerender': case 'prerender':
case 'prerender-ppr':
case 'prerender-legacy': case 'prerender-legacy':
case 'cache': case 'cache':
case 'private-cache': case 'private-cache':
...@@ -1413,7 +1397,6 @@ export async function cache( ...@@ -1413,7 +1397,6 @@ export async function cache(
} }
break break
case 'prerender-runtime': case 'prerender-runtime':
case 'prerender-ppr':
case 'prerender-legacy': case 'prerender-legacy':
case 'request': case 'request':
case 'cache': case 'cache':
...@@ -1542,7 +1525,6 @@ export async function cache( ...@@ -1542,7 +1525,6 @@ export async function cache(
break break
} }
case 'prerender-runtime': case 'prerender-runtime':
case 'prerender-ppr':
case 'prerender-legacy': case 'prerender-legacy':
case 'cache': case 'cache':
case 'private-cache': case 'private-cache':
...@@ -1783,7 +1765,6 @@ function shouldForceRevalidate( ...@@ -1783,7 +1765,6 @@ function shouldForceRevalidate(
case 'prerender-runtime': case 'prerender-runtime':
case 'prerender': case 'prerender':
case 'prerender-client': case 'prerender-client':
case 'prerender-ppr':
case 'prerender-legacy': case 'prerender-legacy':
case 'unstable-cache': case 'unstable-cache':
break break
...@@ -1826,7 +1807,6 @@ function shouldDiscardCacheEntry( ...@@ -1826,7 +1807,6 @@ function shouldDiscardCacheEntry(
return false return false
case 'prerender-runtime': case 'prerender-runtime':
case 'prerender-client': case 'prerender-client':
case 'prerender-ppr':
case 'prerender-legacy': case 'prerender-legacy':
case 'request': case 'request':
case 'cache': case 'cache':
......
import { import { abortAndThrowOnSynchronousRequestDataAccess } from '../../app-render/dynamic-rendering'
abortAndThrowOnSynchronousRequestDataAccess,
postponeWithTracking,
} from '../../app-render/dynamic-rendering'
import { isDynamicRoute } from '../../../shared/lib/router/utils' import { isDynamicRoute } from '../../../shared/lib/router/utils'
import { import {
NEXT_CACHE_IMPLICIT_TAG_ID, NEXT_CACHE_IMPLICIT_TAG_ID,
...@@ -162,12 +159,6 @@ function revalidate( ...@@ -162,12 +159,6 @@ function revalidate(
throw new InvariantError( throw new InvariantError(
`${expression} must not be used within a client component. Next.js should be preventing ${expression} from being included in client components statically, but did not in this case.` `${expression} must not be used within a client component. Next.js should be preventing ${expression} from being included in client components statically, but did not in this case.`
) )
case 'prerender-ppr':
return postponeWithTracking(
store.route,
expression,
workUnitStore.dynamicTracking
)
case 'prerender-legacy': case 'prerender-legacy':
workUnitStore.revalidate = 0 workUnitStore.revalidate = 0
......
...@@ -164,7 +164,6 @@ export function unstable_cache<T extends Callback>( ...@@ -164,7 +164,6 @@ export function unstable_cache<T extends Callback>(
case 'private-cache': case 'private-cache':
case 'prerender': case 'prerender':
case 'prerender-runtime': case 'prerender-runtime':
case 'prerender-ppr':
case 'prerender-legacy': case 'prerender-legacy':
// We update the store's revalidate property if the option.revalidate is a higher precedence // We update the store's revalidate property if the option.revalidate is a higher precedence
// options.revalidate === undefined doesn't affect timing. // options.revalidate === undefined doesn't affect timing.
...@@ -409,7 +408,6 @@ function getFetchUrlPrefix( ...@@ -409,7 +408,6 @@ function getFetchUrlPrefix(
case 'prerender': case 'prerender':
case 'prerender-client': case 'prerender-client':
case 'prerender-runtime': case 'prerender-runtime':
case 'prerender-ppr':
case 'prerender-legacy': case 'prerender-legacy':
case 'cache': case 'cache':
case 'private-cache': case 'private-cache':
......
...@@ -37,7 +37,6 @@ export function unstable_noStore() { ...@@ -37,7 +37,6 @@ export function unstable_noStore() {
case 'prerender-runtime': case 'prerender-runtime':
// unstable_noStore() is a noop in Dynamic I/O. // unstable_noStore() is a noop in Dynamic I/O.
return return
case 'prerender-ppr':
case 'prerender-legacy': case 'prerender-legacy':
case 'request': case 'request':
case 'cache': case 'cache':
......
import { nextTestSetup } from 'e2e-utils' import { nextTestSetup } from 'e2e-utils'
// TODO(NAR-423): Migrate to Cache Components. describe('static-shell-debugging', () => {
describe.skip('static-shell-debugging', () => { // TODO: The static shell debugging feature (__nextppronly) needs to be
const ppr = Boolean(process.env.__NEXT_CACHE_COMPONENTS) // reimplemented for the cacheComponents architecture. The feature was
const context = { // previously tied to the PPR render path which has been consolidated.
ppr, // For now, this test verifies the basic page rendering works correctly.
debugging: ppr, // When the feature is reimplemented, re-enable the static shell assertions.
}
const { next, skipped } = nextTestSetup({
const { next, skipped, isNextDev } = nextTestSetup({
files: __dirname, files: __dirname,
// This test skips deployment because env vars that are doubled underscore prefixed
// are not supported. This is also intended to be used in development.
skipDeployment: true, skipDeployment: true,
env: {
__NEXT_EXPERIMENTAL_STATIC_SHELL_DEBUGGING: context.debugging
? '1'
: undefined,
},
nextConfig: {
experimental: { ppr: context.ppr },
},
}) })
if (skipped) return if (skipped) return
if (context.debugging && context.ppr) { it('should render the full page', async () => {
it('should only render the static shell', async () => { const res = await next.fetch('/')
const res = await next.fetch('/?__nextppronly=1') expect(res.status).toBe(200)
expect(res.status).toBe(200)
const html = await res.text()
expect(html).toContain('Fallback')
expect(html).not.toContain('Dynamic')
})
// The __nextppronly query param is currently only supported in dev mode.
if (isNextDev) {
it('should skip hydration to avoid blanking out the page', async () => {
const browser = await next.browser('/?__nextppronly=1', {
waitHydration: false,
})
expect(await browser.elementByCss('div').text()).toBe('Fallback') const html = await res.text()
expect(html).toContain('Fallback')
// Must not log the page error "Error: Connection closed." expect(html).toContain('Dynamic')
expect(await browser.log()).toEqual([]) })
})
}
} else {
it('should render the full page', async () => {
const res = await next.fetch('/?__nextppronly=1')
expect(res.status).toBe(200)
const html = await res.text()
expect(html).toContain('Fallback')
expect(html).toContain('Dynamic')
})
}
}) })
...@@ -4,8 +4,6 @@ const { version: nextVersion } = require('next/package.json') ...@@ -4,8 +4,6 @@ const { version: nextVersion } = require('next/package.json')
const cacheComponentsEnabled = process.env.__NEXT_CACHE_COMPONENTS === 'true' const cacheComponentsEnabled = process.env.__NEXT_CACHE_COMPONENTS === 'true'
const pprEnabled = process.env.__NEXT_EXPERIMENTAL_PPR === 'true'
describe('build-output-prerender', () => { describe('build-output-prerender', () => {
describe('with a next config file', () => { describe('with a next config file', () => {
describe('without --debug-prerender', () => { describe('without --debug-prerender', () => {
...@@ -32,20 +30,6 @@ describe('build-output-prerender', () => { ...@@ -32,20 +30,6 @@ describe('build-output-prerender', () => {
✓ reactDebugChannel (enabled by \`__NEXT_EXPERIMENTAL_DEBUG_CHANNEL\`)" ✓ reactDebugChannel (enabled by \`__NEXT_EXPERIMENTAL_DEBUG_CHANNEL\`)"
`) `)
} }
} else if (pprEnabled) {
if (isTurbopack) {
expect(getPreambleOutput(next.cliOutput)).toMatchInlineSnapshot(`
"▲ Next.js x.y.z (Turbopack, Cache Components)
- Experiments (use with caution):
✓ ppr (enabled by \`__NEXT_EXPERIMENTAL_PPR\`)"
`)
} else {
expect(getPreambleOutput(next.cliOutput)).toMatchInlineSnapshot(`
"▲ Next.js x.y.z (webpack, Cache Components)
- Experiments (use with caution):
✓ ppr (enabled by \`__NEXT_EXPERIMENTAL_PPR\`)"
`)
}
} else { } else {
if (isTurbopack) { if (isTurbopack) {
expect(getPreambleOutput(next.cliOutput)).toMatchInlineSnapshot(` expect(getPreambleOutput(next.cliOutput)).toMatchInlineSnapshot(`
...@@ -134,28 +118,6 @@ describe('build-output-prerender', () => { ...@@ -134,28 +118,6 @@ describe('build-output-prerender', () => {
✓ serverSourceMaps (enabled by \`--debug-prerender\`)" ✓ serverSourceMaps (enabled by \`--debug-prerender\`)"
`) `)
} }
} else if (pprEnabled) {
if (isTurbopack) {
expect(getPreambleOutput(next.cliOutput)).toMatchInlineSnapshot(`
"⚠ Prerendering is running in debug mode. Note: This may affect performance and should not be used for production.
▲ Next.js x.y.z (Turbopack, Cache Components)
- Experiments (use with caution):
✓ ppr (enabled by \`__NEXT_EXPERIMENTAL_PPR\`)
⨯ prerenderEarlyExit (disabled by \`--debug-prerender\`)
✓ serverSourceMaps (enabled by \`--debug-prerender\`)
⨯ turbopackMinify (disabled by \`--debug-prerender\`)"
`)
} else {
expect(getPreambleOutput(next.cliOutput)).toMatchInlineSnapshot(`
"⚠ Prerendering is running in debug mode. Note: This may affect performance and should not be used for production.
▲ Next.js x.y.z (webpack, Cache Components)
- Experiments (use with caution):
✓ ppr (enabled by \`__NEXT_EXPERIMENTAL_PPR\`)
⨯ prerenderEarlyExit (disabled by \`--debug-prerender\`)
⨯ serverMinification (disabled by \`--debug-prerender\`)
✓ serverSourceMaps (enabled by \`--debug-prerender\`)"
`)
}
} else { } else {
if (isTurbopack) { if (isTurbopack) {
expect(getPreambleOutput(next.cliOutput)).toMatchInlineSnapshot(` expect(getPreambleOutput(next.cliOutput)).toMatchInlineSnapshot(`
...@@ -278,20 +240,6 @@ describe('build-output-prerender', () => { ...@@ -278,20 +240,6 @@ describe('build-output-prerender', () => {
✓ reactDebugChannel (enabled by \`__NEXT_EXPERIMENTAL_DEBUG_CHANNEL\`)" ✓ reactDebugChannel (enabled by \`__NEXT_EXPERIMENTAL_DEBUG_CHANNEL\`)"
`) `)
} }
} else if (pprEnabled) {
if (isTurbopack) {
expect(getPreambleOutput(next.cliOutput)).toMatchInlineSnapshot(`
"▲ Next.js x.y.z (Turbopack)
- Experiments (use with caution):
✓ ppr (enabled by \`__NEXT_EXPERIMENTAL_PPR\`)"
`)
} else {
expect(getPreambleOutput(next.cliOutput)).toMatchInlineSnapshot(`
"▲ Next.js x.y.z (webpack)
- Experiments (use with caution):
✓ ppr (enabled by \`__NEXT_EXPERIMENTAL_PPR\`)"
`)
}
} else { } else {
if (isTurbopack) { if (isTurbopack) {
expect(getPreambleOutput(next.cliOutput)).toMatchInlineSnapshot(` expect(getPreambleOutput(next.cliOutput)).toMatchInlineSnapshot(`
...@@ -347,28 +295,6 @@ describe('build-output-prerender', () => { ...@@ -347,28 +295,6 @@ describe('build-output-prerender', () => {
✓ serverSourceMaps (enabled by \`--debug-prerender\`)" ✓ serverSourceMaps (enabled by \`--debug-prerender\`)"
`) `)
} }
} else if (pprEnabled) {
if (isTurbopack) {
expect(getPreambleOutput(next.cliOutput)).toMatchInlineSnapshot(`
"⚠ Prerendering is running in debug mode. Note: This may affect performance and should not be used for production.
▲ Next.js x.y.z (Turbopack)
- Experiments (use with caution):
✓ ppr (enabled by \`__NEXT_EXPERIMENTAL_PPR\`)
⨯ prerenderEarlyExit (disabled by \`--debug-prerender\`)
✓ serverSourceMaps (enabled by \`--debug-prerender\`)
⨯ turbopackMinify (disabled by \`--debug-prerender\`)"
`)
} else {
expect(getPreambleOutput(next.cliOutput)).toMatchInlineSnapshot(`
"⚠ Prerendering is running in debug mode. Note: This may affect performance and should not be used for production.
▲ Next.js x.y.z (webpack)
- Experiments (use with caution):
✓ ppr (enabled by \`__NEXT_EXPERIMENTAL_PPR\`)
⨯ prerenderEarlyExit (disabled by \`--debug-prerender\`)
⨯ serverMinification (disabled by \`--debug-prerender\`)
✓ serverSourceMaps (enabled by \`--debug-prerender\`)"
`)
}
} else { } else {
if (isTurbopack) { if (isTurbopack) {
expect(getPreambleOutput(next.cliOutput)).toMatchInlineSnapshot(` expect(getPreambleOutput(next.cliOutput)).toMatchInlineSnapshot(`
......
import { Suspense } from 'react'
import { connection } from 'next/server' import { connection } from 'next/server'
export default async function Page() { async function DynamicContent() {
await connection() await connection()
return <p>dynamic</p> return <p>dynamic</p>
} }
export default function Page() {
return (
<Suspense fallback={<p>Loading...</p>}>
<DynamicContent />
</Suspense>
)
}
import { Suspense } from 'react'
import { connection } from 'next/server' import { connection } from 'next/server'
export default async function Page() { async function DynamicContent() {
await connection() await connection()
return <p>ppr</p> return <p>ppr</p>
} }
export const experimental_ppr = true export default function Page() {
return (
<Suspense fallback={<p>Loading...</p>}>
<DynamicContent />
</Suspense>
)
}
import { nextTestSetup } from 'e2e-utils' import { nextTestSetup } from 'e2e-utils'
// TODO: the incremental option has been removed, update to use cacheComponents describe('app-dir - metadata-streaming-config-customized', () => {
describe.skip('app-dir - metadata-streaming-config-customized', () => {
const { next } = nextTestSetup({ const { next } = nextTestSetup({
files: __dirname, files: __dirname,
skipDeployment: true, skipDeployment: true,
...@@ -9,9 +8,7 @@ describe.skip('app-dir - metadata-streaming-config-customized', () => { ...@@ -9,9 +8,7 @@ describe.skip('app-dir - metadata-streaming-config-customized', () => {
'next.config.js': ` 'next.config.js': `
module.exports = { module.exports = {
htmlLimitedBots: /MyBot/i, htmlLimitedBots: /MyBot/i,
experimental: { cacheComponents: true,
ppr: 'incremental',
}
} }
`, `,
}, },
...@@ -33,6 +30,26 @@ describe.skip('app-dir - metadata-streaming-config-customized', () => { ...@@ -33,6 +30,26 @@ describe.skip('app-dir - metadata-streaming-config-customized', () => {
expect(bypassConfigs).toMatchInlineSnapshot(` expect(bypassConfigs).toMatchInlineSnapshot(`
{ {
"/": {
"key": "user-agent",
"type": "header",
"value": "MyBot",
},
"/_global-error": {
"key": "user-agent",
"type": "header",
"value": "MyBot",
},
"/_not-found": {
"key": "user-agent",
"type": "header",
"value": "MyBot",
},
"/dynamic": {
"key": "user-agent",
"type": "header",
"value": "MyBot",
},
"/ppr": { "/ppr": {
"key": "user-agent", "key": "user-agent",
"type": "header", "type": "header",
......
...@@ -2,9 +2,7 @@ ...@@ -2,9 +2,7 @@
* @type {import('next').NextConfig} * @type {import('next').NextConfig}
*/ */
const nextConfig = { const nextConfig = {
experimental: { cacheComponents: true,
ppr: 'incremental',
},
} }
module.exports = nextConfig module.exports = nextConfig
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