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'
import { PAGE_TYPES } from '../../lib/page-types'
import loadCustomRoutes from '../../lib/load-custom-routes'
import { generateRoutesManifest } from '../generate-routes-manifest'
import { checkIsAppPPREnabled } from '../../server/lib/experimental/ppr'
import { normalizeAppPath } from '../../shared/lib/router/utils/app-paths'
import http from 'node:http'
......@@ -188,7 +187,7 @@ async function collectRoutesForAnalyze(
config.basePath ? `${config.basePath}${pathPrefix}` : pathPrefix
)
const isAppPPREnabled = checkIsAppPPREnabled(config.experimental.ppr)
const isAppPPREnabled = !!config.cacheComponents
// Generate routes manifest
const { routesManifest } = generateRoutesManifest({
......
......@@ -7,7 +7,6 @@ import type { ProxyMatcher } from './analysis/get-page-static-info'
import type { Rewrite } from '../lib/load-custom-routes'
import path from 'node:path'
import { needsExperimentalReact } from '../lib/needs-experimental-react'
import { checkIsAppPPREnabled } from '../server/lib/experimental/ppr'
import {
getNextConfigEnv,
getNextPublicEnvironmentVariables,
......@@ -115,7 +114,6 @@ export function getDefineEnv({
const nextPublicEnv = getNextPublicEnvironmentVariables()
const nextConfigEnv = getNextConfigEnv(config)
const isPPREnabled = checkIsAppPPREnabled(config.experimental.ppr)
const isCacheComponentsEnabled = !!config.cacheComponents
const isUseCacheEnabled = !!config.experimental.useCache
......@@ -161,7 +159,6 @@ export function getDefineEnv({
'process.env.__NEXT_APP_NAV_FAIL_HANDLING': Boolean(
config.experimental.appNavFailHandling
),
'process.env.__NEXT_PPR': isPPREnabled,
'process.env.__NEXT_CACHE_COMPONENTS': isCacheComponentsEnabled,
'process.env.__NEXT_USE_CACHE': isUseCacheEnabled,
......
......@@ -199,10 +199,6 @@ import { traceMemoryUsage } from '../lib/memory/trace'
import { generateEncryptionKeyBase64 } from '../server/app-render/encryption-utils-server'
import type { DeepReadonly } from '../shared/lib/deep-readonly'
import uploadTrace from '../trace/upload-trace'
import {
checkIsAppPPREnabled,
checkIsRoutePPREnabled,
} from '../server/lib/experimental/ppr'
import { FallbackMode, fallbackModeToFallbackField } from '../lib/fallback'
import { RenderingMode } from './rendering-mode'
import { InvariantError } from '../shared/lib/invariant-error'
......@@ -1596,7 +1592,7 @@ export default async function build(
const isAuthInterruptsEnabled = Boolean(
config.experimental.authInterrupts
)
const isAppPPREnabled = checkIsAppPPREnabled(config.experimental.ppr)
const isAppPPREnabled = isAppCacheComponentsEnabled
const routesManifestPath = path.join(distDir, ROUTES_MANIFEST)
......@@ -2151,7 +2147,6 @@ export default async function build(
locales: config.i18n?.locales,
defaultLocale: config.i18n?.defaultLocale,
nextConfigOutput: config.output,
pprConfig: config.experimental.ppr,
cacheLifeProfiles: config.cacheLife,
buildId,
sriEnabled,
......@@ -2373,7 +2368,6 @@ export default async function build(
: config.experimental.isrFlushToDisk,
cacheMaxMemorySize: config.cacheMaxMemorySize,
nextConfigOutput: config.output,
pprConfig: config.experimental.ppr,
cacheLifeProfiles: config.cacheLife,
buildId,
sriEnabled,
......@@ -2948,9 +2942,8 @@ export default async function build(
const appConfig = appDefaultConfigs.get(originalAppPath)
const isDynamicError = appConfig?.dynamic === 'error'
const isRoutePPREnabled: boolean = appConfig
? checkIsRoutePPREnabled(config.experimental.ppr)
: false
const isRoutePPREnabled: boolean =
!!appConfig && isAppCacheComponentsEnabled
routes.forEach((route) => {
// If the route has any dynamic root segments, we need to skip
......@@ -3139,8 +3132,7 @@ export default async function build(
// When this is an app page and PPR is enabled, the route supports
// partial pre-rendering.
const isRoutePPREnabled: true | undefined =
!isAppRouteHandler &&
checkIsRoutePPREnabled(config.experimental.ppr)
!isAppRouteHandler && isAppCacheComponentsEnabled
? true
: undefined
......
......@@ -20,7 +20,6 @@ import { BaseServerSpan } from '../../server/lib/trace/constants'
import { interopDefault } from '../../server/app-render/interop-default'
import { stripFlightHeaders } from '../../server/app-render/strip-flight-headers'
import { NodeNextRequest, NodeNextResponse } from '../../server/base-http/node'
import { checkIsAppPPREnabled } from '../../server/lib/experimental/ppr'
import {
getFallbackRouteParams,
createOpaqueFallbackRouteParams,
......@@ -222,12 +221,10 @@ export async function handler(
const isPossibleServerAction = getIsPossibleServerAction(req)
/**
* If the route being rendered is an app page, and the ppr feature has been
* enabled, then the given route _could_ support PPR.
* If the route being rendered is an app page, and the cacheComponents feature
* has been enabled, then the given route _could_ support PPR.
*/
const couldSupportPPR: boolean = checkIsAppPPREnabled(
nextConfig.experimental.ppr
)
const couldSupportPPR: boolean = !!nextConfig.cacheComponents
if (
!getRequestMeta(req, 'postponed') &&
......
......@@ -2,8 +2,6 @@ import type {
NextConfigComplete,
NextConfigRuntime,
} 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 { ServerRuntime } from '../types'
import type { BuildManifest } from '../server/get-page-files'
......@@ -751,7 +749,6 @@ export async function isPageStatic({
cacheHandler,
cacheHandlers,
cacheLifeProfiles,
pprConfig,
buildId,
sriEnabled,
}: {
......@@ -777,7 +774,6 @@ export async function isPageStatic({
[profile: string]: import('../server/use-cache/cache-life').CacheLife
}
nextConfigOutput: 'standalone' | 'export' | undefined
pprConfig: ExperimentalPPRConfig | undefined
buildId: string
sriEnabled: boolean
}): Promise<PageIsStaticResult> {
......@@ -902,12 +898,10 @@ export async function isPageStatic({
rootParamKeys = collectRootParamKeys(routeModule)
// A page supports partial prerendering if it is an app page and either
// the whole app has PPR enabled or this page has PPR enabled when we're
// in incremental mode.
// A page supports partial prerendering if it is an app page and
// cacheComponents is enabled.
isRoutePPREnabled =
routeModule.definition.kind === RouteKind.APP_PAGE &&
checkIsRoutePPREnabled(pprConfig)
routeModule.definition.kind === RouteKind.APP_PAGE && cacheComponents
// If force dynamic was set and we don't have PPR enabled, then set the
// revalidate to 0.
......
......@@ -20,7 +20,6 @@ function hasFallbackRouteParams(): boolean {
switch (workUnitStore.type) {
case 'prerender':
case 'prerender-client':
case 'prerender-ppr':
const fallbackParams = workUnitStore.fallbackRouteParams
return fallbackParams ? fallbackParams.size > 0 : false
case 'prerender-legacy':
......
......@@ -167,15 +167,11 @@ export async function fetchServerResponse(
// Typically, during a navigation, we decode the response using Flight's
// `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>(
url,
headers,
'auto',
shouldImmediatelyDecode
true
)
const responseUrl = urlToUrlWithoutFlightMarker(new URL(res.url))
......
......@@ -2,10 +2,7 @@ import { isHangingPromiseRejectionError } from '../../server/dynamic-rendering-u
import { isPostpone } from '../../server/lib/router-utils/is-postpone'
import { isBailoutToCSRError } from '../../shared/lib/lazy-dynamic/bailout-to-csr'
import { isNextRouterError } from './is-next-router-error'
import {
isDynamicPostpone,
isPrerenderInterruptedError,
} from '../../server/app-render/dynamic-rendering'
import { isPrerenderInterruptedError } from '../../server/app-render/dynamic-rendering'
import { isDynamicServerError } from './hooks-server-context'
export function unstable_rethrow(error: unknown): void {
......@@ -13,7 +10,6 @@ export function unstable_rethrow(error: unknown): void {
isNextRouterError(error) ||
isBailoutToCSRError(error) ||
isDynamicServerError(error) ||
isDynamicPostpone(error) ||
isPostpone(error) ||
isHangingPromiseRejectionError(error) ||
isPrerenderInterruptedError(error)
......
import { isDynamicServerError } from '../../client/components/hooks-server-context'
import { isBailoutToCSRError } from '../../shared/lib/lazy-dynamic/bailout-to-csr'
import { isNextRouterError } from '../../client/components/is-next-router-error'
import { isDynamicPostpone } from '../../server/app-render/dynamic-rendering'
export const isDynamicUsageError = (err: unknown) =>
isDynamicServerError(err) ||
isBailoutToCSRError(err) ||
isNextRouterError(err) ||
isDynamicPostpone(err)
isNextRouterError(err)
......@@ -119,7 +119,6 @@ async function createComponentTreeInternal(
createServerParamsForServerSegment,
createPrerenderParamsForClientSegment,
serverHooks: { DynamicServerError },
Postpone,
},
pagePath,
getDynamicParamFromSegment,
......@@ -304,7 +303,6 @@ async function createComponentTreeInternal(
case 'prerender':
case 'prerender-runtime':
case 'prerender-legacy':
case 'prerender-ppr':
if (workUnitStore.revalidate > defaultRevalidate) {
workUnitStore.revalidate = defaultRevalidate
}
......@@ -689,40 +687,6 @@ async function createComponentTreeInternal(
}
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)
......
......@@ -50,8 +50,6 @@ import { scheduleOnNextTick } from '../../lib/scheduler'
import { BailoutToCSRError } from '../../shared/lib/lazy-dynamic/bailout-to-csr'
import { InvariantError } from '../../shared/lib/invariant-error'
const hasPostpone = typeof React.unstable_postpone === 'function'
export type DynamicAccess = {
/**
* If debugging, this will contain the stack trace of where the dynamic access
......@@ -143,7 +141,6 @@ export function markCurrentScopeAsDynamic(
// A private cache scope is already dynamic by definition.
return
case 'prerender-legacy':
case 'prerender-ppr':
case 'request':
break
default:
......@@ -164,12 +161,6 @@ export function markCurrentScopeAsDynamic(
if (workUnitStore) {
switch (workUnitStore.type) {
case 'prerender-ppr':
return postponeWithTracking(
store.route,
expression,
workUnitStore.dynamicTracking
)
case 'prerender-legacy':
workUnitStore.revalidate = 0
......@@ -239,7 +230,6 @@ export function trackDynamicDataInDynamicRender(workUnitStore: WorkUnitStore) {
case 'prerender':
case 'prerender-runtime':
case 'prerender-legacy':
case 'prerender-ppr':
case 'prerender-client':
break
case 'request':
......@@ -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'
function createPrerenderInterruptedError(message: string): Error {
......@@ -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
* abort semantics slightly.
......@@ -550,7 +460,6 @@ export function createHangingInputAbortSignal(
return controller.signal
case 'prerender-client':
case 'prerender-ppr':
case 'prerender-legacy':
case 'request':
case 'cache':
......@@ -600,17 +509,6 @@ export function useDynamicRouteParams(expression: string) {
}
break
}
case 'prerender-ppr': {
const fallbackParams = workUnitStore.fallbackRouteParams
if (fallbackParams && fallbackParams.size > 0) {
return postponeWithTracking(
workStore.route,
expression,
workUnitStore.dynamicTracking
)
}
break
}
case 'prerender-runtime':
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.`
......@@ -654,8 +552,7 @@ export function useDynamicSearchParams(expression: string) {
)
break
}
case 'prerender-legacy':
case 'prerender-ppr': {
case 'prerender-legacy': {
if (workStore.forceStatic) {
return
}
......
......@@ -276,7 +276,6 @@ export async function decryptActionBoundArgs(
}
break
case 'prerender-client':
case 'prerender-ppr':
case 'prerender-legacy':
case 'request':
case 'cache':
......
......@@ -35,7 +35,6 @@ export { createMetadataComponents } from '../../lib/metadata/metadata'
export { RootLayoutBoundary } from '../../lib/framework/boundary-components'
export { preloadStyle, preloadFont, preconnect } from './rsc/preloads'
export { Postpone } from './rsc/postpone'
export { taintObjectReference } from './rsc/taint'
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>(
return responseOnNextTick
case 'prerender':
case 'prerender-runtime':
case 'prerender-ppr':
case 'prerender-legacy':
case 'request':
case 'cache':
......
......@@ -225,25 +225,6 @@ interface StaticPrerenderStoreCommon {
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
extends CommonWorkUnitStore,
RevalidateStore {
......@@ -251,10 +232,7 @@ export interface PrerenderStoreLegacy
readonly rootParams: Params
}
export type PrerenderStore =
| PrerenderStoreLegacy
| PrerenderStorePPR
| PrerenderStoreModern
export type PrerenderStore = PrerenderStoreLegacy | PrerenderStoreModern
// /** Like `PrerenderStoreModern`, but only including static prerenders (i.e. not runtime prerenders) */
export type StaticPrerenderStore = Exclude<
......@@ -355,7 +333,6 @@ export function getPrerenderResumeDataCache(
switch (workUnitStore.type) {
case 'prerender':
case 'prerender-runtime':
case 'prerender-ppr':
return workUnitStore.prerenderResumeDataCache
case 'prerender-client':
// TODO eliminate fetch caching in client scope and stop exposing this data
......@@ -391,10 +368,8 @@ export function getRenderResumeDataCache(
// that is used to read from prefilled caches.
return workUnitStore.renderResumeDataCache
}
// fallthrough
case 'prerender-ppr':
// Otherwise we return the mutable resume data cache here as an immutable
// version of the cache as it can also be used for reading.
// Otherwise we return the mutable prerender resume data cache here as an
// immutable version of the cache as it can also be used for reading.
return workUnitStore.prerenderResumeDataCache ?? null
case 'cache':
case 'private-cache':
......@@ -420,7 +395,6 @@ export function getHmrRefreshHash(
case 'request':
return workUnitStore.cookies.get(NEXT_HMR_REFRESH_HASH_COOKIE)?.value
case 'prerender-client':
case 'prerender-ppr':
case 'prerender-legacy':
case 'unstable-cache':
break
......@@ -445,7 +419,6 @@ export function isHmrRefresh(
case 'prerender':
case 'prerender-client':
case 'prerender-runtime':
case 'prerender-ppr':
case 'prerender-legacy':
case 'unstable-cache':
break
......@@ -470,7 +443,6 @@ export function getServerComponentsHmrCache(
case 'prerender':
case 'prerender-client':
case 'prerender-runtime':
case 'prerender-ppr':
case 'prerender-legacy':
case 'unstable-cache':
break
......@@ -499,7 +471,6 @@ export function getDraftModeProviderForCacheScope(
return workUnitStore.draftMode
case 'prerender':
case 'prerender-client':
case 'prerender-ppr':
case 'prerender-legacy':
break
default:
......@@ -525,7 +496,6 @@ export function getCacheSignal(
}
// fallthrough
}
case 'prerender-ppr':
case 'prerender-legacy':
case 'cache':
case 'private-cache':
......@@ -545,7 +515,6 @@ export function getRuntimeStagePromise(
return workUnitStore.runtimeStagePromise
case 'prerender':
case 'prerender-client':
case 'prerender-ppr':
case 'prerender-legacy':
case 'request':
case 'cache':
......
......@@ -134,7 +134,6 @@ import { toRoute } from './lib/to-route'
import type { DeepReadonly } from '../shared/lib/deep-readonly'
import { isNodeNextRequest, isNodeNextResponse } from './base-http/helpers'
import { patchSetHeaderWithCookieSupport } from './lib/patch-set-header'
import { checkIsAppPPREnabled } from './lib/experimental/ppr'
import {
getBuiltinRequestContext,
type WaitUntil,
......@@ -423,7 +422,7 @@ export default abstract class Server<
readonly data: NextDataPathnameNormalizer | undefined
}
private readonly isAppPPREnabled: boolean
private readonly isCacheComponentsEnabled: boolean
/**
* This is used to persist cache scopes across
......@@ -505,9 +504,8 @@ export default abstract class Server<
this.enabledDirectories = this.getEnabledDirectories(dev)
this.isAppPPREnabled =
this.enabledDirectories.app &&
checkIsAppPPREnabled(this.nextConfig.experimental.ppr)
this.isCacheComponentsEnabled =
this.enabledDirectories.app && !!this.nextConfig.cacheComponents
this.normalizers = {
// We should normalize the pathname from the RSC prefix only in minimal
......@@ -1056,7 +1054,7 @@ export default abstract class Server<
// It's important to execute the following block even it the request
// matches a pages data route from above.
if (
this.isAppPPREnabled &&
this.isCacheComponentsEnabled &&
this.minimalMode &&
req.headers[NEXT_RESUME_HEADER] === '1' &&
req.method === 'POST'
......@@ -2177,7 +2175,7 @@ export default abstract class Server<
* enabled, then the given route _could_ support PPR.
*/
const couldSupportPPR: boolean =
this.isAppPPREnabled &&
this.isCacheComponentsEnabled &&
typeof routeModule !== 'undefined' &&
isAppPageRouteModule(routeModule)
......
......@@ -11,7 +11,10 @@ import type { WEB_VITALS } from '../shared/lib/utils'
import type { NextParsedUrlQuery } from './request-meta'
import type { SizeLimit } from '../types'
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 { isStableBuild } from '../shared/lib/errors/canary-only-config-error'
import type { FallbackRouteParam } from '../build/static-paths/types'
......
......@@ -1350,9 +1350,6 @@ function assignDefaultsAndValidate(
}
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.
if (result.enablePrerenderSourceMaps === undefined) {
result.enablePrerenderSourceMaps = true
......
......@@ -778,7 +778,6 @@ export default class DevServer extends Server {
distDir: this.distDir,
pathname,
config: {
pprConfig: this.nextConfig.experimental.ppr,
configFileName,
cacheComponents: Boolean(this.nextConfig.cacheComponents),
},
......
......@@ -17,10 +17,6 @@ import { loadComponents } from '../load-components'
import { setHttpClientAndAgentOptions } from '../setup-http-agent-env'
import type { IncrementalCache } from '../lib/incremental-cache'
import { isAppPageRouteModule } from '../route-modules/checks'
import {
checkIsRoutePPREnabled,
type ExperimentalPPRConfig,
} from '../lib/experimental/ppr'
import { InvariantError } from '../../shared/lib/invariant-error'
import { collectRootParamKeys } from '../../build/segment-config/app/collect-root-param-keys'
import { buildAppStaticPaths } from '../../build/static-paths/app'
......@@ -29,7 +25,6 @@ import { createIncrementalCache } from '../../export/helpers/create-incremental-
import { parseAppRoute } from '../../shared/lib/router/routes/app'
type RuntimeConfig = {
pprConfig: ExperimentalPPRConfig | undefined
configFileName: string
cacheComponents: boolean
}
......@@ -126,8 +121,7 @@ export async function loadStaticPaths({
}
const isRoutePPREnabled =
isAppPageRouteModule(routeModule) &&
checkIsRoutePPREnabled(config.pprConfig)
isAppPageRouteModule(routeModule) && config.cacheComponents
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(
case 'prerender-runtime':
// TODO: Stop accumulating tags in client prerender. (fallthrough)
case 'prerender-client':
case 'prerender-ppr':
case 'prerender-legacy':
case 'cache':
case 'private-cache':
......@@ -399,7 +398,6 @@ export function createPatchedFetcher(
case 'prerender':
case 'prerender-client':
case 'prerender-runtime':
case 'prerender-ppr':
case 'prerender-legacy':
case 'request':
case 'cache':
......@@ -568,7 +566,6 @@ export function createPatchedFetcher(
)
}
break
case 'prerender-ppr':
case 'prerender-legacy':
case 'cache':
case 'private-cache':
......@@ -694,7 +691,6 @@ export function createPatchedFetcher(
)
}
break
case 'prerender-ppr':
case 'prerender-legacy':
case 'cache':
case 'private-cache':
......@@ -739,7 +735,6 @@ export function createPatchedFetcher(
case 'prerender':
case 'prerender-client':
case 'prerender-runtime':
case 'prerender-ppr':
case 'prerender-legacy':
case 'unstable-cache':
break
......@@ -885,7 +880,6 @@ export function createPatchedFetcher(
)
}
// fallthrough
case 'prerender-ppr':
case 'prerender-legacy':
case 'cache':
case 'private-cache':
......@@ -966,7 +960,6 @@ export function createPatchedFetcher(
)
}
break
case 'prerender-ppr':
case 'prerender-legacy':
case 'cache':
case 'private-cache':
......@@ -1094,7 +1087,6 @@ export function createPatchedFetcher(
)
}
break
case 'prerender-ppr':
case 'prerender-legacy':
case 'cache':
case 'private-cache':
......@@ -1144,7 +1136,6 @@ export function createPatchedFetcher(
case 'private-cache':
case 'unstable-cache':
case 'prerender-legacy':
case 'prerender-ppr':
break
default:
workUnitStore satisfies never
......
......@@ -244,7 +244,6 @@ function patchConsoleMethod(methodName: InterceptableConsoleMethod): void {
}
// intentional fallthrough
case 'prerender-legacy':
case 'prerender-ppr':
case 'cache':
case 'unstable-cache':
case 'private-cache':
......
......@@ -599,7 +599,6 @@ function filteringUnhandledRejectionHandler(
}
break
}
case 'prerender-ppr':
case 'prerender-legacy':
case 'request':
case 'cache':
......
......@@ -142,7 +142,6 @@ export function io(expression: string, type: ApiType) {
}
}
break
case 'prerender-ppr':
case 'prerender-legacy':
case 'cache':
case 'private-cache':
......
......@@ -4,7 +4,6 @@ import {
workUnitAsyncStorage,
} from '../app-render/work-unit-async-storage.external'
import {
postponeWithTracking,
throwToInterruptStaticGeneration,
trackDynamicDataInDynamicRender,
} from '../app-render/dynamic-rendering'
......@@ -84,14 +83,6 @@ export function connection(): Promise<void> {
workStore.route,
'`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':
// We throw an error here to interrupt prerendering to mark the route
// as dynamic
......
......@@ -16,7 +16,6 @@ import {
} from '../app-render/work-unit-async-storage.external'
import {
delayUntilRuntimeStage,
postponeWithTracking,
throwToInterruptStaticGeneration,
trackDynamicDataInDynamicRender,
} from '../app-render/dynamic-rendering'
......@@ -80,14 +79,6 @@ export function cookies(): Promise<ReadonlyRequestCookies> {
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.`
)
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':
// We track dynamic access here so we don't need to wrap the cookies
// in individual property access tracking.
......
......@@ -13,7 +13,6 @@ import { workUnitAsyncStorage } from '../app-render/work-unit-async-storage.exte
import {
abortAndThrowOnSynchronousRequestDataAccess,
delayUntilRuntimeStage,
postponeWithTracking,
trackDynamicDataInDynamicRender,
} from '../app-render/dynamic-rendering'
import { createDedupedByCallsiteServerErrorLoggerDev } from '../create-deduped-by-callsite-server-error-logger'
......@@ -60,7 +59,6 @@ export function draftMode(): Promise<DraftMode> {
// eslint-disable-next-line no-fallthrough
case 'prerender':
case 'prerender-client':
case 'prerender-ppr':
case 'prerender-legacy':
// Return empty draft mode
return createOrGetCachedDraftMode(null, workStore)
......@@ -221,12 +219,6 @@ function trackDynamicDraftMode(expression: string, constructorOpt: Function) {
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.`
)
case 'prerender-ppr':
return postponeWithTracking(
workStore.route,
expression,
workUnitStore.dynamicTracking
)
case 'prerender-legacy':
workUnitStore.revalidate = 0
......
......@@ -14,7 +14,6 @@ import {
} from '../app-render/work-unit-async-storage.external'
import {
delayUntilRuntimeStage,
postponeWithTracking,
throwToInterruptStaticGeneration,
trackDynamicDataInDynamicRender,
} from '../app-render/dynamic-rendering'
......@@ -78,7 +77,6 @@ export function headers(): Promise<ReadonlyHeaders> {
case 'prerender-client':
case 'private-cache':
case 'prerender-runtime':
case 'prerender-ppr':
case 'prerender-legacy':
case 'request':
break
......@@ -102,16 +100,6 @@ export function headers(): Promise<ReadonlyHeaders> {
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.`
)
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':
// Legacy Prerender
// We are in a legacy static generation mode while prerendering
......
......@@ -5,16 +5,10 @@ import {
import type { OpaqueFallbackRouteParams } from './fallback-params'
import { ReflectAdapter } from '../web/spec-extension/adapters/reflect'
import {
throwToInterruptStaticGeneration,
postponeWithTracking,
delayUntilRuntimeStage,
} from '../app-render/dynamic-rendering'
import { delayUntilRuntimeStage } from '../app-render/dynamic-rendering'
import {
workUnitAsyncStorage,
type PrerenderStorePPR,
type PrerenderStoreLegacy,
type StaticPrerenderStoreModern,
type StaticPrerenderStore,
throwInvariantForMissingStore,
......@@ -46,7 +40,6 @@ export function createParamsFromClient(
switch (workUnitStore.type) {
case 'prerender':
case 'prerender-client':
case 'prerender-ppr':
case 'prerender-legacy':
return createStaticPrerenderParams(
underlyingParams,
......@@ -99,7 +92,6 @@ export function createServerParamsForRoute(
switch (workUnitStore.type) {
case 'prerender':
case 'prerender-client':
case 'prerender-ppr':
case 'prerender-legacy':
return createStaticPrerenderParams(
underlyingParams,
......@@ -145,7 +137,6 @@ export function createServerParamsForServerSegment(
switch (workUnitStore.type) {
case 'prerender':
case 'prerender-client':
case 'prerender-ppr':
case 'prerender-legacy':
return createStaticPrerenderParams(
underlyingParams,
......@@ -220,7 +211,6 @@ export function createPrerenderParamsForClientSegment(
throw new InvariantError(
'createPrerenderParamsForClientSegment should not be called in cache contexts.'
)
case 'prerender-ppr':
case 'prerender-legacy':
case 'prerender-runtime':
case 'request':
......@@ -261,22 +251,6 @@ function createStaticPrerenderParams(
}
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':
break
default:
......@@ -378,65 +352,6 @@ function makeHangingParams(
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> {
const cachedParams = CachedParams.get(underlyingParams)
if (cachedParams) {
......
import type { WorkStore } from '../app-render/work-async-storage.external'
import {
delayUntilRuntimeStage,
postponeWithTracking,
type DynamicTrackingState,
} from '../app-render/dynamic-rendering'
import { delayUntilRuntimeStage } from '../app-render/dynamic-rendering'
import {
throwInvariantForMissingStore,
......@@ -23,7 +19,6 @@ export function createServerPathnameForMetadata(
switch (workUnitStore.type) {
case 'prerender':
case 'prerender-client':
case 'prerender-ppr':
case 'prerender-legacy': {
return createPrerenderPathname(
underlyingPathname,
......@@ -73,13 +68,6 @@ function createPrerenderPathname(
}
break
}
case 'prerender-ppr': {
const fallbackParams = prerenderStore.fallbackRouteParams
if (fallbackParams && fallbackParams.size > 0) {
return makeErroringPathname(workStore, prerenderStore.dynamicTracking)
}
break
}
case 'prerender-legacy':
break
default:
......@@ -90,41 +78,6 @@ function createPrerenderPathname(
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> {
return Promise.resolve(underlyingPathname)
}
import { InvariantError } from '../../shared/lib/invariant-error'
import {
postponeWithTracking,
throwToInterruptStaticGeneration,
} from '../app-render/dynamic-rendering'
import {
workAsyncStorage,
type WorkStore,
} from '../app-render/work-async-storage.external'
import {
workUnitAsyncStorage,
type PrerenderStoreLegacy,
type PrerenderStorePPR,
type StaticPrerenderStore,
} from '../app-render/work-unit-async-storage.external'
import { makeHangingPromise } from '../dynamic-rendering-utils'
import type { ParamValue } from './params'
import { describeStringPropertyAccess } from '../../shared/lib/utils/reflect-utils'
import { actionAsyncStorage } from '../app-render/action-async-storage.external'
/**
......@@ -65,7 +58,6 @@ export function getRootParam(paramName: string): Promise<ParamValue> {
}
case 'prerender':
case 'prerender-client':
case 'prerender-ppr':
case 'prerender-legacy': {
return createPrerenderRootParamPromise(
paramName,
......@@ -100,7 +92,6 @@ function createPrerenderRootParamPromise(
}
case 'prerender':
case 'prerender-legacy':
case 'prerender-ppr':
default:
}
......@@ -122,22 +113,6 @@ function createPrerenderRootParamPromise(
}
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': {
// legacy prerenders can't have fallback params
break
......@@ -150,36 +125,3 @@ function createPrerenderRootParamPromise(
// If the param is not a fallback param, we just return the statically available value.
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'
import { ReflectAdapter } from '../web/spec-extension/adapters/reflect'
import {
throwToInterruptStaticGeneration,
postponeWithTracking,
annotateDynamicAccess,
delayUntilRuntimeStage,
} from '../app-render/dynamic-rendering'
......@@ -11,7 +10,6 @@ import {
import {
workUnitAsyncStorage,
type PrerenderStoreLegacy,
type PrerenderStorePPR,
type PrerenderStoreModern,
type PrerenderStoreModernRuntime,
type StaticPrerenderStore,
......@@ -46,7 +44,6 @@ export function createSearchParamsFromClient(
switch (workUnitStore.type) {
case 'prerender':
case 'prerender-client':
case 'prerender-ppr':
case 'prerender-legacy':
return createStaticPrerenderSearchParams(workStore, workUnitStore)
case 'prerender-runtime':
......@@ -85,7 +82,6 @@ export function createServerSearchParamsForServerPage(
switch (workUnitStore.type) {
case 'prerender':
case 'prerender-client':
case 'prerender-ppr':
case 'prerender-legacy':
return createStaticPrerenderSearchParams(workStore, workUnitStore)
case 'cache':
......@@ -143,7 +139,6 @@ export function createPrerenderSearchParamsForClientPage(
throw new InvariantError(
'createPrerenderSearchParamsForClientPage should not be called in cache contexts.'
)
case 'prerender-ppr':
case 'prerender-legacy':
case 'request':
return Promise.resolve({})
......@@ -169,7 +164,6 @@ function createStaticPrerenderSearchParams(
case 'prerender-client':
// We are in a cacheComponents (PPR or otherwise) prerender
return makeHangingSearchParams(workStore, prerenderStore)
case 'prerender-ppr':
case 'prerender-legacy':
// We are in a legacy static generation and need to interrupt the
// prerender when search params are accessed.
......@@ -273,7 +267,7 @@ function makeHangingSearchParams(
function makeErroringSearchParams(
workStore: WorkStore,
prerenderStore: PrerenderStoreLegacy | PrerenderStorePPR
prerenderStore: PrerenderStoreLegacy
): Promise<SearchParams> {
const cachedSearchParams = CachedSearchParams.get(workStore)
if (cachedSearchParams) {
......@@ -303,13 +297,6 @@ function makeErroringSearchParams(
workStore.route,
expression
)
} else if (prerenderStore.type === 'prerender-ppr') {
// PPR Prerender (no cacheComponents)
postponeWithTracking(
workStore.route,
expression,
prerenderStore.dynamicTracking
)
} else {
// Legacy Prerender
throwToInterruptStaticGeneration(
......
......@@ -60,7 +60,6 @@ import { StaticGenBailoutError } from '../../../client/components/static-generat
import { isStaticGenEnabled } from './helpers/is-static-gen-enabled'
import {
abortAndThrowOnSynchronousRequestDataAccess,
postponeWithTracking,
createDynamicTrackingState,
getFirstDynamicReason,
} from '../../app-render/dynamic-rendering'
......@@ -1209,12 +1208,6 @@ function trackDynamic(
throw new InvariantError(
'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':
workUnitStore.revalidate = 0
......
......@@ -87,7 +87,6 @@ export function cacheLife(profile: CacheLifeProfiles | CacheLife): void {
case 'prerender':
case 'prerender-client':
case 'prerender-runtime':
case 'prerender-ppr':
case 'prerender-legacy':
case 'request':
case 'unstable-cache':
......
......@@ -14,7 +14,6 @@ export function cacheTag(...tags: string[]): void {
case 'prerender':
case 'prerender-client':
case 'prerender-runtime':
case 'prerender-ppr':
case 'prerender-legacy':
case 'request':
case 'unstable-cache':
......
......@@ -58,7 +58,6 @@ import { getCacheHandler } from './handlers'
import { UseCacheTimeoutError } from './use-cache-errors'
import {
createHangingInputAbortSignal,
postponeWithTracking,
throwToInterruptStaticGeneration,
} from '../app-render/dynamic-rendering'
import {
......@@ -230,7 +229,6 @@ function createUseCacheStore(
break
case 'prerender-runtime':
case 'prerender':
case 'prerender-ppr':
case 'prerender-legacy':
case 'unstable-cache':
break
......@@ -364,7 +362,6 @@ function propagateCacheLifeAndTags(
case 'private-cache':
case 'prerender':
case 'prerender-runtime':
case 'prerender-ppr':
case 'prerender-legacy':
propagateCacheLifeAndTagsToRevalidateStore(
cacheContext.outerWorkUnitStore,
......@@ -487,8 +484,7 @@ async function collectResult(
case 'private-cache':
case 'cache':
case 'unstable-cache':
case 'prerender-legacy':
case 'prerender-ppr': {
case 'prerender-legacy': {
propagateCacheLifeAndTags(cacheContext, entry)
break
}
......@@ -564,7 +560,6 @@ async function generateCacheEntryImpl(
}
})
break
case 'prerender-ppr':
case 'prerender-legacy':
case 'request':
case 'cache':
......@@ -706,7 +701,6 @@ async function generateCacheEntryImpl(
await new Promise((resolve) => setTimeout(resolve))
}
// fallthrough
case 'prerender-ppr':
case 'prerender-legacy':
case 'cache':
case 'private-cache':
......@@ -887,12 +881,6 @@ export async function cache(
workStore.route,
expression
)
case 'prerender-ppr':
return postponeWithTracking(
workStore.route,
expression,
workUnitStore.dynamicTracking
)
case 'prerender-legacy':
return throwToInterruptStaticGeneration(
expression,
......@@ -952,7 +940,6 @@ export async function cache(
)
case 'prerender':
case 'prerender-runtime':
case 'prerender-ppr':
case 'prerender-legacy':
case 'request':
case 'cache':
......@@ -1198,7 +1185,6 @@ export async function cache(
break
}
// fallthrough
case 'prerender-ppr':
case 'prerender-legacy':
case 'request':
// TODO(restart-on-cache-miss): We need to handle params/searchParams on page components.
......@@ -1301,7 +1287,6 @@ export async function cache(
}
break
}
case 'prerender-ppr':
case 'prerender-legacy':
case 'cache':
case 'private-cache':
......@@ -1350,7 +1335,6 @@ export async function cache(
break
}
case 'prerender':
case 'prerender-ppr':
case 'prerender-legacy':
case 'cache':
case 'private-cache':
......@@ -1413,7 +1397,6 @@ export async function cache(
}
break
case 'prerender-runtime':
case 'prerender-ppr':
case 'prerender-legacy':
case 'request':
case 'cache':
......@@ -1542,7 +1525,6 @@ export async function cache(
break
}
case 'prerender-runtime':
case 'prerender-ppr':
case 'prerender-legacy':
case 'cache':
case 'private-cache':
......@@ -1783,7 +1765,6 @@ function shouldForceRevalidate(
case 'prerender-runtime':
case 'prerender':
case 'prerender-client':
case 'prerender-ppr':
case 'prerender-legacy':
case 'unstable-cache':
break
......@@ -1826,7 +1807,6 @@ function shouldDiscardCacheEntry(
return false
case 'prerender-runtime':
case 'prerender-client':
case 'prerender-ppr':
case 'prerender-legacy':
case 'request':
case 'cache':
......
import {
abortAndThrowOnSynchronousRequestDataAccess,
postponeWithTracking,
} from '../../app-render/dynamic-rendering'
import { abortAndThrowOnSynchronousRequestDataAccess } from '../../app-render/dynamic-rendering'
import { isDynamicRoute } from '../../../shared/lib/router/utils'
import {
NEXT_CACHE_IMPLICIT_TAG_ID,
......@@ -162,12 +159,6 @@ function revalidate(
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.`
)
case 'prerender-ppr':
return postponeWithTracking(
store.route,
expression,
workUnitStore.dynamicTracking
)
case 'prerender-legacy':
workUnitStore.revalidate = 0
......
......@@ -164,7 +164,6 @@ export function unstable_cache<T extends Callback>(
case 'private-cache':
case 'prerender':
case 'prerender-runtime':
case 'prerender-ppr':
case 'prerender-legacy':
// We update the store's revalidate property if the option.revalidate is a higher precedence
// options.revalidate === undefined doesn't affect timing.
......@@ -409,7 +408,6 @@ function getFetchUrlPrefix(
case 'prerender':
case 'prerender-client':
case 'prerender-runtime':
case 'prerender-ppr':
case 'prerender-legacy':
case 'cache':
case 'private-cache':
......
......@@ -37,7 +37,6 @@ export function unstable_noStore() {
case 'prerender-runtime':
// unstable_noStore() is a noop in Dynamic I/O.
return
case 'prerender-ppr':
case 'prerender-legacy':
case 'request':
case 'cache':
......
import { nextTestSetup } from 'e2e-utils'
// TODO(NAR-423): Migrate to Cache Components.
describe.skip('static-shell-debugging', () => {
const ppr = Boolean(process.env.__NEXT_CACHE_COMPONENTS)
const context = {
ppr,
debugging: ppr,
}
const { next, skipped, isNextDev } = nextTestSetup({
describe('static-shell-debugging', () => {
// TODO: The static shell debugging feature (__nextppronly) needs to be
// reimplemented for the cacheComponents architecture. The feature was
// previously tied to the PPR render path which has been consolidated.
// For now, this test verifies the basic page rendering works correctly.
// When the feature is reimplemented, re-enable the static shell assertions.
const { next, skipped } = nextTestSetup({
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,
env: {
__NEXT_EXPERIMENTAL_STATIC_SHELL_DEBUGGING: context.debugging
? '1'
: undefined,
},
nextConfig: {
experimental: { ppr: context.ppr },
},
})
if (skipped) return
if (context.debugging && context.ppr) {
it('should only render the static shell', async () => {
const res = await next.fetch('/?__nextppronly=1')
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,
})
it('should render the full page', async () => {
const res = await next.fetch('/')
expect(res.status).toBe(200)
expect(await browser.elementByCss('div').text()).toBe('Fallback')
// Must not log the page error "Error: Connection closed."
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')
})
}
const html = await res.text()
expect(html).toContain('Fallback')
expect(html).toContain('Dynamic')
})
})
......@@ -4,8 +4,6 @@ const { version: nextVersion } = require('next/package.json')
const cacheComponentsEnabled = process.env.__NEXT_CACHE_COMPONENTS === 'true'
const pprEnabled = process.env.__NEXT_EXPERIMENTAL_PPR === 'true'
describe('build-output-prerender', () => {
describe('with a next config file', () => {
describe('without --debug-prerender', () => {
......@@ -32,20 +30,6 @@ describe('build-output-prerender', () => {
✓ 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 {
if (isTurbopack) {
expect(getPreambleOutput(next.cliOutput)).toMatchInlineSnapshot(`
......@@ -134,28 +118,6 @@ describe('build-output-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 {
if (isTurbopack) {
expect(getPreambleOutput(next.cliOutput)).toMatchInlineSnapshot(`
......@@ -278,20 +240,6 @@ describe('build-output-prerender', () => {
✓ 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 {
if (isTurbopack) {
expect(getPreambleOutput(next.cliOutput)).toMatchInlineSnapshot(`
......@@ -347,28 +295,6 @@ describe('build-output-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 {
if (isTurbopack) {
expect(getPreambleOutput(next.cliOutput)).toMatchInlineSnapshot(`
......
import { Suspense } from 'react'
import { connection } from 'next/server'
export default async function Page() {
async function DynamicContent() {
await connection()
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'
export default async function Page() {
async function DynamicContent() {
await connection()
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'
// TODO: the incremental option has been removed, update to use cacheComponents
describe.skip('app-dir - metadata-streaming-config-customized', () => {
describe('app-dir - metadata-streaming-config-customized', () => {
const { next } = nextTestSetup({
files: __dirname,
skipDeployment: true,
......@@ -9,9 +8,7 @@ describe.skip('app-dir - metadata-streaming-config-customized', () => {
'next.config.js': `
module.exports = {
htmlLimitedBots: /MyBot/i,
experimental: {
ppr: 'incremental',
}
cacheComponents: true,
}
`,
},
......@@ -33,6 +30,26 @@ describe.skip('app-dir - metadata-streaming-config-customized', () => {
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": {
"key": "user-agent",
"type": "header",
......
......@@ -2,9 +2,7 @@
* @type {import('next').NextConfig}
*/
const nextConfig = {
experimental: {
ppr: 'incremental',
},
cacheComponents: true,
}
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