Unverified Commit ac6d9932 authored by Josh Story's avatar Josh Story Committed by GitHub

Add unstable_prefetch route segment config and decouple runtime prefetching…

 Add unstable_prefetch route segment config and decouple runtime prefetching from unstable_instant (#92754)

Allows you to opt into runtime prefetching without coupling it to the
way you configure instant validation. We do not intend to allow shipping
runtime prefetching without opting into instant validation unless you
specifically disable the validation because the cost of the runtime
prefetching is potentially high but the way you configure validation is
likely going to be pulling in lots of test code and we want to make it
easier to discern that the validation code is not going to be bundled
into production builds so separating the config is helpful.

Another reason to separate the config is that we expect that eventually
most prefetching is configured globally and you do not need to opt
specific segments into a different prefetching strategy.

Improved client component error messages to accurately describe the
constraint: these are route segment configs that require a Server
Component module, not exports that are forbidden.
parent 9c53486a
......@@ -119,6 +119,9 @@ pub struct NextSegmentConfig {
#[turbo_tasks(trace_ignore)]
#[bincode(with_serde)]
pub unstable_instant: Option<Span>,
#[turbo_tasks(trace_ignore)]
#[bincode(with_serde)]
pub unstable_prefetch: Option<Span>,
}
#[turbo_tasks::value_impl]
......@@ -533,9 +536,25 @@ pub async fn parse_segment_config_from_source(
"unstable_instant",
span,
rcstr!(
"App pages cannot export \"unstable_instant\" from a Client Component module. \
To use this API, convert this module to a Server Component by removing the \
\"use client\" directive."
"\"unstable_instant\" is a route segment config and can only be used when the \
segment is a Server Component module. Remove the \"use client\" directive to \
use this API."
),
None,
IssueSeverity::Error,
)
.await?;
}
if let Some(span) = config.unstable_prefetch {
invalid_config(
source,
"unstable_prefetch",
span,
rcstr!(
"\"unstable_prefetch\" is a route segment config and can only be used when \
the segment is a Server Component module. Remove the \"use client\" \
directive to use this API."
),
None,
IssueSeverity::Error,
......@@ -962,6 +981,9 @@ async fn parse_config_value(
"unstable_instant" => {
config.unstable_instant = Some(span);
}
"unstable_prefetch" => {
config.unstable_prefetch = Some(span);
}
_ => {}
}
......
......@@ -1156,5 +1156,9 @@
"1155": "Not implemented",
"1156": "Cannot create a replay stream after the ReplayableNodeStream has been disposed.",
"1157": "`unstable_io()` requires the `experimental.unstableIO` option to be enabled in your Next.js config.",
"1158": "The prerender-ppr work unit type has been removed. This code path should be unreachable."
"1158": "The prerender-ppr work unit type has been removed. This code path should be unreachable.",
"1159": "\"unstable_instant\" is a route segment config and can only be used when the segment is a Server Component module. Remove the \"use client\" directive from \"%s\" to use this API.",
"1160": "Route \"%s\" cannot use \\`export const unstable_prefetch = ...\\` without enabling \\`cacheComponents\\`.",
"1161": "\"unstable_prefetch\" is a route segment config and can only be used when the segment is a Server Component module. Remove the \"use client\" directive from \"%s\" to use this API.",
"1162": "Route \"%s\" cannot use \\`export const unstable_instant = ...\\` without enabling \\`cacheComponents\\`."
}
......@@ -681,13 +681,26 @@ export async function getAppPageStaticInfo({
// Prevent use client and unstable_instant in the same file.
if (directives?.has('client') && 'unstable_instant' in config) {
throw new Error(
`Page "${page}" cannot export "unstable_instant" from a Client Component module. To use this API, convert this module to a Server Component by removing the "use client" directive.`
`"unstable_instant" is a route segment config and can only be used when the segment is a Server Component module. Remove the "use client" directive from "${pageFilePath}" to use this API.`
)
}
if ('unstable_instant' in config && !nextConfig.cacheComponents) {
throw new Error(
`Page "${page}" cannot use \`export const unstable_instant = ...\` without enabling \`cacheComponents\`.`
`Route "${page}" cannot use \`export const unstable_instant = ...\` without enabling \`cacheComponents\`.`
)
}
// Prevent use client and unstable_prefetch in the same file.
if (directives?.has('client') && 'unstable_prefetch' in config) {
throw new Error(
`"unstable_prefetch" is a route segment config and can only be used when the segment is a Server Component module. Remove the "use client" directive from "${pageFilePath}" to use this API.`
)
}
if ('unstable_prefetch' in config && !nextConfig.cacheComponents) {
throw new Error(
`Route "${page}" cannot use \`export const unstable_prefetch = ...\` without enabling \`cacheComponents\`.`
)
}
......
......@@ -49,8 +49,12 @@ const InstantConfigSchema = z.union([
z.literal(false),
])
const PrefetchSchema = z.enum(['static', 'runtime'])
export type Instant = InstantConfigStatic | InstantConfigRuntime | false
export type Prefetch = 'static' | 'runtime'
export type InstantConfigForTypeCheckInternal = __GenericInstantConfig | Instant
// the __GenericPrefetch type is used to avoid type widening issues with
// our choice to make exports the medium for programming a Next.js application
......@@ -145,6 +149,13 @@ const AppSegmentConfigSchema = z.object({
*/
unstable_instant: InstantConfigSchema.optional(),
/**
* Controls runtime prefetching for this segment.
* 'static' is a noop (default behavior).
* 'runtime' enables runtime prefetching.
*/
unstable_prefetch: PrefetchSchema.optional(),
/**
* The stale time for dynamic responses in seconds.
* Controls how long the client-side router cache retains dynamic page data.
......@@ -195,6 +206,11 @@ export function parseAppSegmentConfig(
message: `Invalid unstable_instant value ${JSON.stringify(ctx.data)} on "${route}", must be an object with \`prefetch: "static"\` or \`prefetch: "runtime"\`, or \`false\`. Read more at https://nextjs.org/docs/messages/invalid-instant-configuration`,
}
}
case 'unstable_prefetch': {
return {
message: `Invalid unstable_prefetch value ${JSON.stringify(ctx.data)} on "${route}", must be "static" or "runtime".`,
}
}
case 'unstable_dynamicStaleTime': {
return {
message: `Invalid unstable_dynamicStaleTime value ${JSON.stringify(ctx.data)} on "${route}", must be a non-negative number`,
......@@ -254,6 +270,13 @@ export type AppSegmentConfig = {
*/
unstable_instant?: Instant
/**
* Controls runtime prefetching for this segment.
* 'static' is a noop (default behavior).
* 'runtime' enables runtime prefetching.
*/
unstable_prefetch?: Prefetch
/**
* The stale time for dynamic responses in seconds.
* Controls how long the client-side router cache retains dynamic page data.
......
......@@ -54,7 +54,7 @@ ${
: `import type { ResolvingMetadata, ResolvingViewport } from 'next/dist/lib/metadata/types/metadata-interface.js'`
}
import type { InstantConfigForTypeCheckInternal } from 'next/dist/build/segment-config/app/app-segment-config.js'
import type { InstantConfigForTypeCheckInternal, Prefetch } from 'next/dist/build/segment-config/app/app-segment-config.js'
type TEntry = typeof import('${relativePath}.js')
......@@ -72,6 +72,7 @@ checkFields<Diff<{
config?: {}
generateStaticParams?: Function
unstable_instant?: InstantConfigForTypeCheckInternal
unstable_prefetch?: Prefetch
unstable_dynamicStaleTime?: number
revalidate?: RevalidateRange<TEntry> | false
dynamic?: 'auto' | 'force-dynamic' | 'error' | 'force-static'
......
......@@ -243,13 +243,10 @@ async function createComponentTreeInternal(
})
: []
const instantConfig = layoutOrPageMod
? (layoutOrPageMod as AppSegmentConfig).unstable_instant
const prefetchConfig = layoutOrPageMod
? (layoutOrPageMod as AppSegmentConfig).unstable_prefetch
: undefined
const hasRuntimePrefetch =
instantConfig && typeof instantConfig === 'object'
? instantConfig.prefetch === 'runtime'
: false
const hasRuntimePrefetch = prefetchConfig === 'runtime'
const isRuntimePrefetchable = hasRuntimePrefetch || parentRuntimePrefetchable
const [Forbidden, forbiddenStyles] =
......
......@@ -28,11 +28,14 @@ async function createFlightRouterStateFromLoaderTreeImpl(
{},
]
// Load the layout or page module to check for unstable_instant config
// Load the layout or page module to check for unstable_instant/unstable_prefetch config
const mod = layout ? await layout[0]() : page ? await page[0]() : undefined
const instantConfig = mod
? (mod as AppSegmentConfig).unstable_instant
: undefined
const prefetchConfig = mod
? (mod as AppSegmentConfig).unstable_prefetch
: undefined
let prefetchHints = 0
// Union in the precomputed build-time hints (e.g. segment inlining
......@@ -89,9 +92,10 @@ async function createFlightRouterStateFromLoaderTreeImpl(
prefetchHints |= PrefetchHint.PrefetchDisabled
} else if (instantConfig && typeof instantConfig === 'object') {
prefetchHints |= PrefetchHint.SubtreeHasInstant
if (instantConfig.prefetch === 'runtime') {
prefetchHints |= PrefetchHint.HasRuntimePrefetch
}
}
if (prefetchConfig === 'runtime') {
prefetchHints |= PrefetchHint.HasRuntimePrefetch
}
// Check if this segment has a loading boundary
......
......@@ -16,14 +16,10 @@ export async function anySegmentHasRuntimePrefetchEnabled(
const { mod: layoutOrPageMod } = await getLayoutOrPageModule(tree)
// TODO(restart-on-cache-miss): Does this work correctly for client page/layout modules?
const instantConfig = layoutOrPageMod
? (layoutOrPageMod as AppSegmentConfig).unstable_instant
const prefetchConfig = layoutOrPageMod
? (layoutOrPageMod as AppSegmentConfig).unstable_prefetch
: undefined
const hasRuntimePrefetch =
instantConfig && typeof instantConfig === 'object'
? instantConfig.prefetch === 'runtime'
: false
if (hasRuntimePrefetch) {
if (prefetchConfig === 'runtime') {
return true
}
......
......@@ -1146,10 +1146,13 @@ export async function createCombinedPayloadAtDepth(
: createChildSegmentPath(parentPath, key!, segment)
let instantConfig: Instant | null = null
let prefetchConfig: AppSegmentConfig['unstable_prefetch'] | null = null
let localCreateInstantStack: (() => Error) | null = null
if (layoutOrPageMod !== undefined) {
instantConfig =
(layoutOrPageMod as AppSegmentConfig).unstable_instant ?? null
prefetchConfig =
(layoutOrPageMod as AppSegmentConfig).unstable_prefetch ?? null
if (instantConfig && typeof instantConfig === 'object') {
const rawFactory: unknown = (layoutOrPageMod as any)
.__debugCreateInstantConfigStack
......@@ -1158,14 +1161,12 @@ export async function createCombinedPayloadAtDepth(
}
}
const segmentHasRuntimePrefetch = prefetchConfig === 'runtime'
let childIsInsideRuntimePrefetch = isInsideRuntimePrefetch
let stage: SegmentStage
if (!isInsideRuntimePrefetch) {
if (
instantConfig &&
typeof instantConfig === 'object' &&
instantConfig.prefetch === 'runtime'
) {
if (segmentHasRuntimePrefetch) {
stage = RenderStage.Runtime
childIsInsideRuntimePrefetch = true
hasRuntimeSegments = true
......
......@@ -4,6 +4,7 @@ import { connection } from 'next/server'
import { Suspense } from 'react'
export const unstable_instant = { prefetch: 'runtime', samples: [{}] }
export const unstable_prefetch = 'runtime'
const CACHE_KEY = __dirname + '/__PAGE__'
......
......@@ -3,6 +3,7 @@ import { UncachedFetch, CachedData } from '../data-fetching'
import { PrivateCachedData } from './data-fetching'
export const unstable_instant = { prefetch: 'runtime', samples: [{}] }
export const unstable_prefetch = 'runtime'
const CACHE_KEY = '/private-cache/__LAYOUT__'
......
......@@ -3,6 +3,7 @@ import { UncachedFetch, CachedData } from '../data-fetching'
import { ShortLivedCache } from './data-fetching'
export const unstable_instant = { prefetch: 'runtime', samples: [{}] }
export const unstable_prefetch = 'runtime'
const CACHE_KEY = __dirname + '/__LAYOUT__'
......
......@@ -2,6 +2,7 @@ import { Suspense } from 'react'
import { UncachedFetch, CachedFetch, CachedData } from '../data-fetching'
export const unstable_instant = { prefetch: 'runtime', samples: [{}] }
export const unstable_prefetch = 'runtime'
const CACHE_KEY = __dirname + '/__LAYOUT__'
......
export const unstable_instant = { prefetch: 'runtime', samples: [{}] }
export const unstable_prefetch = 'runtime'
export default async function Page() {
return (
......
......@@ -3,6 +3,7 @@ import { CachedData, getCachedData } from '../../data-fetching'
import { cookies } from 'next/headers'
export const unstable_instant = { prefetch: 'runtime', samples: [{}] }
export const unstable_prefetch = 'runtime'
const CACHE_KEY = __dirname + '/__PAGE__'
......
import { CachedData, getCachedData } from '../../data-fetching'
export const unstable_instant = { prefetch: 'runtime', samples: [{}] }
export const unstable_prefetch = 'runtime'
const CACHE_KEY = __dirname + '/__PAGE__'
......
......@@ -2,6 +2,7 @@ import { Suspense } from 'react'
import { Static, Runtime, Dynamic } from '../shared'
export const unstable_instant = { prefetch: 'runtime', samples: [{}] }
export const unstable_prefetch = 'runtime'
export default function Root({ children }: { children: React.ReactNode }) {
return (
......
......@@ -5,6 +5,7 @@ export const unstable_instant = {
prefetch: 'runtime',
samples: [{ searchParams: { myParam: 'testValue' } }],
}
export const unstable_prefetch = 'runtime'
type SearchParams = { [key: string]: string | string[] | undefined }
......
......@@ -6,6 +6,7 @@ export const unstable_instant = {
prefetch: 'runtime',
samples: [{ cookies: [] }],
}
export const unstable_prefetch = 'runtime'
export default async function Page() {
return (
......
......@@ -6,6 +6,7 @@ export const unstable_instant = {
prefetch: 'runtime',
samples: [{ cookies: [] }],
}
export const unstable_prefetch = 'runtime'
export default async function Page() {
return (
......
......@@ -6,6 +6,7 @@ export const unstable_instant = {
prefetch: 'runtime',
samples: [{ cookies: [] }],
}
export const unstable_prefetch = 'runtime'
export default async function Page() {
return (
......
......@@ -15,6 +15,7 @@ export const unstable_instant: Instant = {
},
],
}
export const unstable_prefetch = 'runtime'
export default async function Page() {
return (
......
......@@ -10,6 +10,7 @@ export const unstable_instant: Instant = {
},
],
}
export const unstable_prefetch = 'runtime'
export default async function Page() {
return (
......
......@@ -10,6 +10,7 @@ export const unstable_instant: Instant = {
},
],
}
export const unstable_prefetch = 'runtime'
export default async function Page() {
return (
......
......@@ -16,6 +16,7 @@ export const unstable_instant: Instant = {
},
],
}
export const unstable_prefetch = 'runtime'
export function generateStaticParams() {
return [{ slug: 'foo' }, { slug: 'bar' }]
......
......@@ -6,6 +6,7 @@ export const unstable_instant = {
prefetch: 'runtime',
samples: [{ headers: [] }],
}
export const unstable_prefetch = 'runtime'
export default async function Page() {
return (
......
......@@ -6,6 +6,7 @@ export const unstable_instant = {
prefetch: 'runtime',
samples: [{ headers: [] }],
}
export const unstable_prefetch = 'runtime'
export default async function Page() {
return (
......
......@@ -6,6 +6,7 @@ export const unstable_instant = {
prefetch: 'runtime',
samples: [{ headers: [] }],
}
export const unstable_prefetch = 'runtime'
export default async function Page() {
return (
......
......@@ -15,6 +15,7 @@ export const unstable_instant: Instant = {
},
],
}
export const unstable_prefetch = 'runtime'
export default async function Page() {
return (
......
......@@ -10,6 +10,7 @@ export const unstable_instant: Instant = {
},
],
}
export const unstable_prefetch = 'runtime'
export default async function Page() {
return (
......
......@@ -10,6 +10,7 @@ export const unstable_instant: Instant = {
},
],
}
export const unstable_prefetch = 'runtime'
export default async function Page() {
return (
......
......@@ -5,6 +5,7 @@ export const unstable_instant = {
prefetch: 'runtime',
samples: [{ cookies: [{ name: 'auth', value: '1' }] }],
}
export const unstable_prefetch = 'runtime'
export default async function Page() {
const c = await cookies()
......
......@@ -13,6 +13,7 @@ export const unstable_instant: Instant = {
},
],
}
export const unstable_prefetch = 'runtime'
export default async function Page({
params,
......
......@@ -13,6 +13,7 @@ export const unstable_instant: Instant = {
},
],
}
export const unstable_prefetch = 'runtime'
export default async function Page({
params,
......
......@@ -12,6 +12,7 @@ export const unstable_instant: Instant = {
},
],
}
export const unstable_prefetch = 'runtime'
export default async function Page({
params,
......
......@@ -5,6 +5,7 @@ export const unstable_instant: Instant = {
prefetch: 'runtime',
samples: [{ params: { slug: 'hello' } }],
}
export const unstable_prefetch = 'runtime'
export default async function Page({
params,
......
......@@ -5,6 +5,7 @@ export const unstable_instant: Instant = {
prefetch: 'runtime',
samples: [{ params: { slug: 'hello' } }],
}
export const unstable_prefetch = 'runtime'
export default async function Page({
params,
......
......@@ -4,6 +4,7 @@ export const unstable_instant = {
prefetch: 'runtime',
samples: [{ searchParams: { q: 'test' } }],
}
export const unstable_prefetch = 'runtime'
export default async function Page({
searchParams,
......
......@@ -4,6 +4,7 @@ export const unstable_instant = {
prefetch: 'runtime',
samples: [{ searchParams: { q: 'test' } }],
}
export const unstable_prefetch = 'runtime'
export default async function Page({
searchParams,
......
......@@ -12,6 +12,7 @@ export const unstable_instant: Instant = {
},
],
}
export const unstable_prefetch = 'runtime'
export default function Page() {
return (
......
......@@ -11,6 +11,7 @@ export const unstable_instant: Instant = {
},
],
}
export const unstable_prefetch = 'runtime'
export default function Page() {
return (
......
......@@ -16,6 +16,7 @@ export const unstable_instant: Instant = {
},
],
}
export const unstable_prefetch = 'runtime'
type SearchParams = Record<string, string | string[]>
......
......@@ -12,6 +12,7 @@ export const unstable_instant: Instant = {
},
],
}
export const unstable_prefetch = 'runtime'
export default async function Page({
searchParams,
......
......@@ -14,6 +14,7 @@ export const unstable_instant: Instant = {
},
],
}
export const unstable_prefetch = 'runtime'
export default async function Page({
searchParams,
......
......@@ -14,6 +14,7 @@ export const unstable_instant: Instant = {
},
],
}
export const unstable_prefetch = 'runtime'
export default function Page() {
return (
......
......@@ -5,6 +5,7 @@ export const unstable_instant = {
prefetch: 'runtime',
samples: [{ cookies: [] }],
}
export const unstable_prefetch = 'runtime'
export default function Page() {
return (
......
......@@ -4,6 +4,7 @@ export const unstable_instant = {
prefetch: 'runtime',
samples: [{ cookies: [] }],
}
export const unstable_prefetch = 'runtime'
export default function Page() {
return (
......
......@@ -4,6 +4,7 @@ export const unstable_instant = {
prefetch: 'runtime',
samples: [{ cookies: [] }],
}
export const unstable_prefetch = 'runtime'
export default function Page() {
return (
......
......@@ -4,6 +4,7 @@ export const unstable_instant = {
prefetch: 'runtime',
samples: [{}],
}
export const unstable_prefetch = 'runtime'
export default async function Page() {
await cachedIO('static')
......
......@@ -2,6 +2,7 @@ export const unstable_instant = {
prefetch: 'runtime',
samples: [{}],
}
export const unstable_prefetch = 'runtime'
export default async function Page() {
await privateCachedIO()
......
......@@ -4,6 +4,7 @@ export const unstable_instant = {
prefetch: 'runtime',
samples: [{}],
}
export const unstable_prefetch = 'runtime'
export default async function Page() {
await cookies()
......
......@@ -6,6 +6,7 @@ export const unstable_instant = {
prefetch: 'runtime',
samples: [{ cookies: [{ name: 'auth', value: '1' }] }],
}
export const unstable_prefetch = 'runtime'
export default async function Page() {
return (
......
......@@ -8,6 +8,7 @@ export const unstable_instant: Instant = {
// no samples
samples: [{}],
}
export const unstable_prefetch = 'runtime'
export default async function Page() {
// Guard behind cookies() so that the rest of this component only runs during validation
......
......@@ -8,6 +8,7 @@ export const unstable_instant: Instant = {
// no samples
samples: [{}],
}
export const unstable_prefetch = 'runtime'
export default async function Page() {
// Guard behind cookies() so that the rest of this component only runs during validation
......
......@@ -7,6 +7,7 @@ export const unstable_instant: Instant = {
prefetch: 'runtime',
samples: [{ params: { lang: 'en-from-samples' } }],
}
export const unstable_prefetch = 'runtime'
export default async function Page() {
// Guard behind cookies() so that the rest of this component only runs during validation
......
......@@ -13,9 +13,7 @@ describe('app dir - instant-validation-client', () => {
}
it('should error when a client component exports unstable_instant', async () => {
const expectedErrMsg = process.env.IS_TURBOPACK_TEST
? `Next.js can't recognize the exported \`unstable_instant\` field in route. App pages cannot export "unstable_instant" from a Client Component module. To use this API, convert this module to a Server Component by removing the "use client" directive.`
: `Page "/page" cannot export "unstable_instant" from a Client Component module. To use this API, convert this module to a Server Component by removing the "use client" directive.`
const expectedErrMsg = `"unstable_instant" is a route segment config and can only be used when the segment is a Server Component module. Remove the "use client" directive`
if (isNextDev) {
await next.start().catch(() => {})
......
......@@ -3,6 +3,7 @@ export const unstable_instant = {
samples: [{ cookies: [] }],
unstable_disableValidation: true,
}
export const unstable_prefetch = 'runtime'
export default function Layout({ children }) {
return <>{children}</>
......
......@@ -5,6 +5,7 @@ export const unstable_instant = {
samples: [{ cookies: [] }],
unstable_disableValidation: true,
}
export const unstable_prefetch = 'runtime'
export default async function Page() {
await connection()
......
......@@ -5,6 +5,7 @@ export const unstable_instant = {
samples: [{ cookies: [] }],
unstable_disableValidation: true,
}
export const unstable_prefetch = 'runtime'
export default async function Page() {
await connection()
......
......@@ -7,6 +7,7 @@ export const unstable_instant = {
prefetch: 'runtime',
samples: [{ cookies: [] }],
}
export const unstable_prefetch = 'runtime'
// Note that we're inside a root layout with suspense, so we skip the static shell
export async function generateViewport(): Promise<Viewport> {
......
......@@ -2,6 +2,7 @@ export const unstable_instant = {
prefetch: 'runtime',
samples: [{ cookies: [] }],
}
export const unstable_prefetch = 'runtime'
export default async function Layout({ children }) {
return <>{children}</>
......
......@@ -7,6 +7,7 @@ export const unstable_instant = {
prefetch: 'runtime',
samples: [{ cookies: [] }],
}
export const unstable_prefetch = 'runtime'
export async function generateMetadata(): Promise<Metadata> {
await connection()
......
......@@ -5,6 +5,7 @@ export const unstable_instant = {
prefetch: 'runtime',
samples: [{ cookies: [] }],
}
export const unstable_prefetch = 'runtime'
export async function generateViewport(): Promise<Viewport> {
await cookies()
......
......@@ -5,6 +5,7 @@ export const unstable_instant = {
prefetch: 'runtime',
samples: [{}],
}
export const unstable_prefetch = 'runtime'
export default function SlotPage() {
return (
......
......@@ -4,6 +4,7 @@ export const unstable_instant = {
prefetch: 'runtime',
samples: [{ cookies: [] }],
}
export const unstable_prefetch = 'runtime'
export default async function RuntimeLayout({ children }) {
await cookies()
......
// Avoid static shell validation -- we only want to test the validation of `prefetch: 'runtime'` here.
export const unstable_instant = false
export const unstable_prefetch = 'runtime'
export default function DisableStaticShell({ children }) {
return <>{children}</>
......
......@@ -4,6 +4,7 @@ export const unstable_instant = {
prefetch: 'runtime',
samples: [{ cookies: [] }],
}
export const unstable_prefetch = 'runtime'
// This page HAS runtime prefetch enabled. cookies() is passed as a promise
// input to a public "use cache" function. The cache doesn't read the cookies
......
......@@ -5,6 +5,7 @@ export const unstable_instant = {
prefetch: 'runtime',
samples: [{ cookies: [] }],
}
export const unstable_prefetch = 'runtime'
export async function generateMetadata() {
await cookies()
......
......@@ -5,6 +5,7 @@ export const unstable_instant = {
prefetch: 'runtime',
samples: [{ cookies: [] }],
}
export const unstable_prefetch = 'runtime'
async function Runtime() {
await cookies()
......
......@@ -4,6 +4,7 @@ export const unstable_instant = {
prefetch: 'runtime',
samples: [{ cookies: [] }],
}
export const unstable_prefetch = 'runtime'
// This page HAS runtime prefetch enabled. The sync IO (Date.now()) after
// cookies() is invalid here because during a runtime prefetch, cookies()
......
......@@ -4,6 +4,7 @@ export const unstable_instant = {
prefetch: 'runtime',
samples: [{ cookies: [] }],
}
export const unstable_prefetch = 'runtime'
export default async function Page() {
await cookies()
......
......@@ -5,6 +5,7 @@ export const unstable_instant = {
prefetch: 'runtime',
samples: [{ cookies: [] }],
}
export const unstable_prefetch = 'runtime'
export default async function Layout({ children }: { children: ReactNode }) {
await connection()
......
......@@ -5,6 +5,7 @@ export const unstable_instant = {
prefetch: 'runtime',
samples: [{ cookies: [] }],
}
export const unstable_prefetch = 'runtime'
export default async function Page() {
await cookies()
......
......@@ -7,6 +7,7 @@ export const unstable_instant = {
prefetch: 'runtime',
samples: [{ cookies: [] }],
}
export const unstable_prefetch = 'runtime'
export default function InnerLayout({ children }: { children: ReactNode }) {
return (
......
......@@ -6,6 +6,7 @@ export const unstable_instant = {
prefetch: 'runtime',
samples: [{ cookies: [] }],
}
export const unstable_prefetch = 'runtime'
export default async function Page() {
return (
......
......@@ -5,6 +5,7 @@ export const unstable_instant = {
prefetch: 'runtime',
samples: [{ cookies: [] }],
}
export const unstable_prefetch = 'runtime'
export default async function Page() {
await cookies()
......
......@@ -5,6 +5,7 @@ export const unstable_instant = {
prefetch: 'runtime',
samples: [{ cookies: [] }],
}
export const unstable_prefetch = 'runtime'
export default async function RuntimeLayout({ children }) {
await cookies()
......
......@@ -5,6 +5,7 @@ export const unstable_instant = {
prefetch: 'runtime',
samples: [{ cookies: [], params: { param: '123' } }],
}
export const unstable_prefetch = 'runtime'
export default async function Page({
params,
......
......@@ -5,6 +5,7 @@ export const unstable_instant = {
prefetch: 'runtime',
samples: [{ cookies: [], searchParams: { foo: 'bar' } }],
}
export const unstable_prefetch = 'runtime'
export default async function Page({
searchParams,
......
......@@ -5,6 +5,7 @@ export const unstable_instant = {
prefetch: 'runtime',
samples: [{ cookies: [] }],
}
export const unstable_prefetch = 'runtime'
async function Runtime() {
await cookies()
......
......@@ -4,6 +4,7 @@ export const unstable_instant = {
prefetch: 'runtime',
samples: [{ cookies: [{ name: 'test', value: null }] }],
}
export const unstable_prefetch = 'runtime'
export default function Layout({ children }: { children: ReactNode }) {
return <div>{children}</div>
......
......@@ -6,6 +6,7 @@ export const unstable_instant = {
prefetch: 'runtime',
samples: [{ cookies: [{ name: 'test', value: null }] }],
}
export const unstable_prefetch = 'runtime'
export default async function Page() {
return (
......
......@@ -14,6 +14,7 @@ export const unstable_instant = {
},
],
}
export const unstable_prefetch = 'runtime'
export default async function Page({
searchParams,
......
......@@ -15,6 +15,7 @@ export const unstable_instant = {
},
],
}
export const unstable_prefetch = 'runtime'
async function LayoutContent({ children }: { children: ReactNode }) {
const cookieStore = await cookies()
......
......@@ -4,6 +4,7 @@ export const unstable_instant = {
prefetch: 'runtime',
samples: [{ cookies: [{ name: 'theme', value: 'default' }] }],
}
export const unstable_prefetch = 'runtime'
export default async function RuntimeBailoutPage() {
const cookieStore = await cookies()
......
......@@ -9,6 +9,7 @@ export const unstable_instant = {
prefetch: 'runtime',
samples: [{ cookies: [{ name: 'theme', value: 'default' }] }],
}
export const unstable_prefetch = 'runtime'
async function DynamicContent() {
const cookieStore = await cookies()
......
......@@ -9,6 +9,7 @@ export const unstable_instant = {
prefetch: 'runtime',
samples: [{ cookies: [{ name: 'theme', value: 'default' }] }],
}
export const unstable_prefetch = 'runtime'
async function DynamicContent() {
const cookieStore = await cookies()
......
......@@ -5,6 +5,7 @@ export const unstable_instant = {
prefetch: 'runtime',
samples: [{ cookies: [] }],
}
export const unstable_prefetch = 'runtime'
export default function Page() {
return (
......
......@@ -6,6 +6,7 @@ export const unstable_instant = {
prefetch: 'runtime',
samples: [{ cookies: [] }],
}
export const unstable_prefetch = 'runtime'
export default async function Layout({ children }) {
return (
<main>
......
......@@ -6,6 +6,7 @@ export const unstable_instant = {
prefetch: 'runtime',
samples: [{ cookies: [] }],
}
export const unstable_prefetch = 'runtime'
export default async function Page() {
return (
......
......@@ -6,6 +6,7 @@ export const unstable_instant = {
prefetch: 'runtime',
samples: [{ cookies: [] }],
}
export const unstable_prefetch = 'runtime'
export default async function Page() {
return (
......
......@@ -6,6 +6,7 @@ export const unstable_instant = {
prefetch: 'runtime',
samples: [{ cookies: [] }],
}
export const unstable_prefetch = 'runtime'
export default async function Page() {
return (
......
......@@ -6,6 +6,7 @@ export const unstable_instant = {
prefetch: 'runtime',
samples: [{ cookies: [] }],
}
export const unstable_prefetch = 'runtime'
export default async function Page() {
return (
......
......@@ -6,6 +6,7 @@ export const unstable_instant = {
prefetch: 'runtime',
samples: [{ cookies: [] }],
}
export const unstable_prefetch = 'runtime'
export default async function Page() {
return (
......
......@@ -10,6 +10,7 @@ export const unstable_instant = {
unstable_disableValidation: true,
samples: [{ cookies: [{ name: 'user-agent', value: null }] }],
}
export const unstable_prefetch = 'runtime'
export default async function Page() {
return (
......
......@@ -9,6 +9,7 @@ export const unstable_instant = {
unstable_disableValidation: true,
samples: [{ cookies: [] }],
}
export const unstable_prefetch = 'runtime'
export default async function Page() {
return (
......
......@@ -10,6 +10,7 @@ export const unstable_instant = {
unstable_disableValidation: true,
samples: [{ cookies: [] }],
}
export const unstable_prefetch = 'runtime'
export default async function Page({ params }: { params: Promise<Params> }) {
return (
......
......@@ -9,6 +9,7 @@ export const unstable_instant = {
unstable_disableValidation: true,
samples: [{ cookies: [] }],
}
export const unstable_prefetch = 'runtime'
export default async function Page() {
return (
......
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