`\`${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.`
...
...
@@ -564,7 +667,8 @@ export function useDynamicSearchParams(expression: string) {
@@ -92,6 +93,14 @@ export function connection(): Promise<void> {
`${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 use React's postpone API to interrupt rendering here to create a
// dynamic hole
returnpostponeWithTracking(
workStore.route,
'connection',
workUnitStore.dynamicTracking
)
case'prerender-legacy':
// We throw an error here to interrupt prerendering to mark the route
@@ -81,6 +82,14 @@ export function cookies(): Promise<ReadonlyRequestCookies> {
thrownewInvariantError(
`${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.
returnpostponeWithTracking(
workStore.route,
callingExpression,
workUnitStore.dynamicTracking
)
case'prerender-legacy':
// We track dynamic access here so we don't need to wrap the cookies
@@ -58,6 +59,7 @@ export function draftMode(): Promise<DraftMode> {
// Otherwise, we fall through to providing an empty draft mode.
// eslint-disable-next-line no-fallthrough
case'prerender':
case'prerender-ppr':
case'prerender-legacy':
// Return empty draft mode
returncreateOrGetCachedDraftMode(null,workStore)
...
...
@@ -226,6 +228,12 @@ function trackDynamicDraftMode(expression: string, constructorOpt: Function) {
thrownewInvariantError(
`${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.`
@@ -79,6 +80,7 @@ export function headers(): Promise<ReadonlyHeaders> {
case'validation-client':
case'private-cache':
case'prerender-runtime':
case'prerender-ppr':
case'prerender-legacy':
case'request':
break
...
...
@@ -103,6 +105,16 @@ export function headers(): Promise<ReadonlyHeaders> {
thrownewInvariantError(
`${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
returnpostponeWithTracking(
workStore.route,
callingExpression,
workUnitStore.dynamicTracking
)
case'prerender-legacy':
// Legacy Prerender
// We are in a legacy static generation mode while prerendering
`${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.`