Unverified Commit 3a832f1e authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Add cache scope handling for dynamic IO for dev/build (#70408)

As discussed this adds an in memory cache scope which is leveraged for
seeding during prefetch and then leveraged during non-prefetch requests
in development and during build it shares a cache scope across one build
worker. During production server mode the cache scopes are specific
per-request with no prefetch cache seeding.
parent 4337bc26
...@@ -1897,6 +1897,7 @@ export default async function build( ...@@ -1897,6 +1897,7 @@ export default async function build(
distDir, distDir,
configFileName, configFileName,
runtimeEnvConfig, runtimeEnvConfig,
dynamicIO: Boolean(config.experimental.dynamicIO),
httpAgentOptions: config.httpAgentOptions, httpAgentOptions: config.httpAgentOptions,
locales: config.i18n?.locales, locales: config.i18n?.locales,
defaultLocale: config.i18n?.defaultLocale, defaultLocale: config.i18n?.defaultLocale,
...@@ -2112,6 +2113,7 @@ export default async function build( ...@@ -2112,6 +2113,7 @@ export default async function build(
pageRuntime, pageRuntime,
edgeInfo, edgeInfo,
pageType, pageType,
dynamicIO: Boolean(config.experimental.dynamicIO),
cacheHandler: config.cacheHandler, cacheHandler: config.cacheHandler,
isrFlushToDisk: ciEnvironment.hasNextSupport isrFlushToDisk: ciEnvironment.hasNextSupport
? false ? false
......
...@@ -1348,6 +1348,7 @@ export async function buildAppStaticPaths({ ...@@ -1348,6 +1348,7 @@ export async function buildAppStaticPaths({
dir, dir,
page, page,
distDir, distDir,
dynamicIO,
configFileName, configFileName,
generateParams, generateParams,
isrFlushToDisk, isrFlushToDisk,
...@@ -1362,6 +1363,7 @@ export async function buildAppStaticPaths({ ...@@ -1362,6 +1363,7 @@ export async function buildAppStaticPaths({
}: { }: {
dir: string dir: string
page: string page: string
dynamicIO: boolean
configFileName: string configFileName: string
generateParams: GenerateParamsResults generateParams: GenerateParamsResults
distDir: string distDir: string
...@@ -1390,6 +1392,7 @@ export async function buildAppStaticPaths({ ...@@ -1390,6 +1392,7 @@ export async function buildAppStaticPaths({
const incrementalCache = new IncrementalCache({ const incrementalCache = new IncrementalCache({
fs: nodeFs, fs: nodeFs,
dev: true, dev: true,
dynamicIO,
flushToDisk: isrFlushToDisk, flushToDisk: isrFlushToDisk,
serverDistDir: path.join(distDir, 'server'), serverDistDir: path.join(distDir, 'server'),
fetchCacheKeyPrefix, fetchCacheKeyPrefix,
...@@ -1581,6 +1584,7 @@ export async function isPageStatic({ ...@@ -1581,6 +1584,7 @@ export async function isPageStatic({
pageRuntime, pageRuntime,
edgeInfo, edgeInfo,
pageType, pageType,
dynamicIO,
originalAppPath, originalAppPath,
isrFlushToDisk, isrFlushToDisk,
maxMemoryCacheSize, maxMemoryCacheSize,
...@@ -1592,6 +1596,7 @@ export async function isPageStatic({ ...@@ -1592,6 +1596,7 @@ export async function isPageStatic({
dir: string dir: string
page: string page: string
distDir: string distDir: string
dynamicIO: boolean
configFileName: string configFileName: string
runtimeEnvConfig: any runtimeEnvConfig: any
httpAgentOptions: NextConfigComplete['httpAgentOptions'] httpAgentOptions: NextConfigComplete['httpAgentOptions']
...@@ -1722,6 +1727,7 @@ export async function isPageStatic({ ...@@ -1722,6 +1727,7 @@ export async function isPageStatic({
await buildAppStaticPaths({ await buildAppStaticPaths({
dir, dir,
page, page,
dynamicIO,
configFileName, configFileName,
generateParams, generateParams,
distDir, distDir,
......
...@@ -63,6 +63,7 @@ export interface StaticGenerationStore { ...@@ -63,6 +63,7 @@ export interface StaticGenerationStore {
isDraftMode?: boolean isDraftMode?: boolean
isUnstableNoStore?: boolean isUnstableNoStore?: boolean
isPrefetchRequest?: boolean
requestEndedState?: { ended?: boolean } requestEndedState?: { ended?: boolean }
} }
......
...@@ -7,12 +7,14 @@ import { formatDynamicImportPath } from '../../lib/format-dynamic-import-path' ...@@ -7,12 +7,14 @@ import { formatDynamicImportPath } from '../../lib/format-dynamic-import-path'
export async function createIncrementalCache({ export async function createIncrementalCache({
cacheHandler, cacheHandler,
dynamicIO,
cacheMaxMemorySize, cacheMaxMemorySize,
fetchCacheKeyPrefix, fetchCacheKeyPrefix,
distDir, distDir,
dir, dir,
flushToDisk, flushToDisk,
}: { }: {
dynamicIO: boolean
cacheHandler?: string cacheHandler?: string
cacheMaxMemorySize?: number cacheMaxMemorySize?: number
fetchCacheKeyPrefix?: string fetchCacheKeyPrefix?: string
...@@ -34,6 +36,7 @@ export async function createIncrementalCache({ ...@@ -34,6 +36,7 @@ export async function createIncrementalCache({
dev: false, dev: false,
requestHeaders: {}, requestHeaders: {},
flushToDisk, flushToDisk,
dynamicIO,
fetchCache: true, fetchCache: true,
maxMemoryCacheSize: cacheMaxMemorySize, maxMemoryCacheSize: cacheMaxMemorySize,
fetchCacheKeyPrefix, fetchCacheKeyPrefix,
......
...@@ -46,6 +46,7 @@ import { ...@@ -46,6 +46,7 @@ import {
type FallbackRouteParams, type FallbackRouteParams,
} from '../server/request/fallback-params' } from '../server/request/fallback-params'
import { needsExperimentalReact } from '../lib/needs-experimental-react' import { needsExperimentalReact } from '../lib/needs-experimental-react'
import { runWithCacheScope } from '../server/async-storage/cache-scope'
const envConfig = require('../shared/lib/runtime-config.external') const envConfig = require('../shared/lib/runtime-config.external')
...@@ -352,6 +353,7 @@ export async function exportPages( ...@@ -352,6 +353,7 @@ export async function exportPages(
fetchCacheKeyPrefix, fetchCacheKeyPrefix,
distDir, distDir,
dir, dir,
dynamicIO: Boolean(nextConfig.experimental.dynamicIO),
// skip writing to disk in minimal mode for now, pending some // skip writing to disk in minimal mode for now, pending some
// changes to better support it // changes to better support it
flushToDisk: !hasNextSupport, flushToDisk: !hasNextSupport,
...@@ -459,21 +461,26 @@ export async function exportPages( ...@@ -459,21 +461,26 @@ export async function exportPages(
return { result, path, pageKey } return { result, path, pageKey }
} }
// for each build worker we share one dynamic IO cache scope
// this is only leveraged if the flag is enabled
const dynamicIOCacheScope = new Map()
for (let i = 0; i < paths.length; i += maxConcurrency) { await runWithCacheScope({ cache: dynamicIOCacheScope }, async () => {
const subset = paths.slice(i, i + maxConcurrency) for (let i = 0; i < paths.length; i += maxConcurrency) {
const subset = paths.slice(i, i + maxConcurrency)
const subsetResults = await Promise.all( const subsetResults = await Promise.all(
subset.map((path) => subset.map((path) =>
exportPageWithRetry( exportPageWithRetry(
path, path,
nextConfig.experimental.staticGenerationRetryCount ?? 1 nextConfig.experimental.staticGenerationRetryCount ?? 1
)
) )
) )
)
results.push(...subsetResults) results.push(...subsetResults)
} }
})
return results return results
} }
......
...@@ -1284,6 +1284,7 @@ export const renderToHTMLOrFlight: AppPageRender = ( ...@@ -1284,6 +1284,7 @@ export const renderToHTMLOrFlight: AppPageRender = (
fallbackRouteParams, fallbackRouteParams,
renderOpts, renderOpts,
requestEndedState, requestEndedState,
isPrefetchRequest: Boolean(req.headers[NEXT_ROUTER_PREFETCH_HEADER]),
}, },
(staticGenerationStore) => (staticGenerationStore) =>
renderToHTMLOrFlightImpl( renderToHTMLOrFlightImpl(
......
import { AsyncLocalStorage } from 'async_hooks'
export interface CacheScopeStore {
cache?: Map<string, any>
}
export const cacheScopeAsyncLocalStorage =
new AsyncLocalStorage<CacheScopeStore>()
/**
* For dynamic IO handling we want to have a scoped memory
* cache which can live either the lifetime of a build worker,
* the lifetime of a specific request, or from a prefetch request
* to the request for non-prefetch version of a page (with
* drop-off after so long to prevent memory inflating)
*/
export function runWithCacheScope(
store: Partial<CacheScopeStore>,
fn: (...args: any[]) => Promise<any>
) {
return cacheScopeAsyncLocalStorage.run(
{
cache: store.cache || new Map(),
},
fn
)
}
...@@ -21,6 +21,7 @@ export type StaticGenerationContext = { ...@@ -21,6 +21,7 @@ export type StaticGenerationContext = {
fallbackRouteParams: FallbackRouteParams | null fallbackRouteParams: FallbackRouteParams | null
requestEndedState?: { ended?: boolean } requestEndedState?: { ended?: boolean }
isPrefetchRequest?: boolean
renderOpts: { renderOpts: {
incrementalCache?: IncrementalCache incrementalCache?: IncrementalCache
isOnDemandRevalidate?: boolean isOnDemandRevalidate?: boolean
...@@ -69,6 +70,7 @@ export const withStaticGenerationStore: WithStore< ...@@ -69,6 +70,7 @@ export const withStaticGenerationStore: WithStore<
fallbackRouteParams, fallbackRouteParams,
renderOpts, renderOpts,
requestEndedState, requestEndedState,
isPrefetchRequest,
}: StaticGenerationContext, }: StaticGenerationContext,
callback: (store: StaticGenerationStore) => Result callback: (store: StaticGenerationStore) => Result
): Result => { ): Result => {
...@@ -111,6 +113,7 @@ export const withStaticGenerationStore: WithStore< ...@@ -111,6 +113,7 @@ export const withStaticGenerationStore: WithStore<
isDraftMode: renderOpts.isDraftMode, isDraftMode: renderOpts.isDraftMode,
requestEndedState, requestEndedState,
isPrefetchRequest,
} }
// TODO: remove this when we resolve accessing the store outside the execution context // TODO: remove this when we resolve accessing the store outside the execution context
......
...@@ -173,6 +173,11 @@ import type { RouteModule } from './route-modules/route-module' ...@@ -173,6 +173,11 @@ import type { RouteModule } from './route-modules/route-module'
import { FallbackMode, parseFallbackField } from '../lib/fallback' import { FallbackMode, parseFallbackField } from '../lib/fallback'
import { toResponseCacheEntry } from './response-cache/utils' import { toResponseCacheEntry } from './response-cache/utils'
import { scheduleOnNextTick } from '../lib/scheduler' import { scheduleOnNextTick } from '../lib/scheduler'
import { PrefetchCacheScopes } from './lib/prefetch-cache-scopes'
import {
runWithCacheScope,
type CacheScopeStore,
} from './async-storage/cache-scope'
export type FindComponentsResult = { export type FindComponentsResult = {
components: LoadComponentsReturnType components: LoadComponentsReturnType
...@@ -454,6 +459,14 @@ export default abstract class Server< ...@@ -454,6 +459,14 @@ export default abstract class Server<
private readonly isAppPPREnabled: boolean private readonly isAppPPREnabled: boolean
private readonly prefetchCacheScopesDev = new PrefetchCacheScopes()
/**
* This is used to persist cache scopes across
* prefetch -> full route requests for dynamic IO
* it's only fully used in dev
*/
public constructor(options: ServerOptions) { public constructor(options: ServerOptions) {
const { const {
dir = '.', dir = '.',
...@@ -2748,7 +2761,7 @@ export default abstract class Server< ...@@ -2748,7 +2761,7 @@ export default abstract class Server<
} }
} }
const responseGenerator: ResponseGenerator = async ({ let responseGenerator: ResponseGenerator = async ({
hasResolved, hasResolved,
previousCacheEntry, previousCacheEntry,
isRevalidating, isRevalidating,
...@@ -2999,6 +3012,54 @@ export default abstract class Server< ...@@ -2999,6 +3012,54 @@ export default abstract class Server<
} }
} }
if (this.nextConfig.experimental.dynamicIO) {
const originalResponseGenerator = responseGenerator
responseGenerator = async (
...args: Parameters<typeof responseGenerator>
): ReturnType<typeof responseGenerator> => {
let cache: CacheScopeStore['cache'] | undefined
if (this.renderOpts.dev) {
cache = this.prefetchCacheScopesDev.get(urlPathname)
// we need to seed the prefetch cache scope in dev
// since we did not have a prefetch cache available
// and this is not a prefetch request
if (
!cache &&
!isPrefetchRSCRequest &&
routeModule?.definition.kind === RouteKind.APP_PAGE
) {
req.headers[RSC_HEADER] = '1'
req.headers[NEXT_ROUTER_PREFETCH_HEADER] = '1'
cache = new Map()
await runWithCacheScope({ cache }, () =>
originalResponseGenerator(...args)
)
this.prefetchCacheScopesDev.set(urlPathname, cache)
delete req.headers[RSC_HEADER]
delete req.headers[NEXT_ROUTER_PREFETCH_HEADER]
}
}
return runWithCacheScope({ cache }, () =>
originalResponseGenerator(...args)
).finally(() => {
if (this.renderOpts.dev) {
if (isPrefetchRSCRequest) {
this.prefetchCacheScopesDev.set(urlPathname, cache)
} else {
this.prefetchCacheScopesDev.del(urlPathname)
}
}
})
}
}
const cacheEntry = await this.responseCache.get( const cacheEntry = await this.responseCache.get(
ssgCacheKey, ssgCacheKey,
responseGenerator, responseGenerator,
......
...@@ -762,6 +762,7 @@ export default class DevServer extends Server { ...@@ -762,6 +762,7 @@ export default class DevServer extends Server {
configFileName, configFileName,
publicRuntimeConfig, publicRuntimeConfig,
serverRuntimeConfig, serverRuntimeConfig,
dynamicIO: Boolean(this.nextConfig.experimental.dynamicIO),
}, },
httpAgentOptions, httpAgentOptions,
locales, locales,
......
...@@ -30,6 +30,7 @@ type RuntimeConfig = { ...@@ -30,6 +30,7 @@ type RuntimeConfig = {
configFileName: string configFileName: string
publicRuntimeConfig: { [key: string]: any } publicRuntimeConfig: { [key: string]: any }
serverRuntimeConfig: { [key: string]: any } serverRuntimeConfig: { [key: string]: any }
dynamicIO: boolean
} }
// we call getStaticPaths in a separate process to ensure // we call getStaticPaths in a separate process to ensure
...@@ -115,6 +116,7 @@ export async function loadStaticPaths({ ...@@ -115,6 +116,7 @@ export async function loadStaticPaths({
return await buildAppStaticPaths({ return await buildAppStaticPaths({
dir, dir,
page: pathname, page: pathname,
dynamicIO: config.dynamicIO,
generateParams, generateParams,
configFileName: config.configFileName, configFileName: config.configFileName,
distDir, distDir,
......
...@@ -10,6 +10,7 @@ import { ...@@ -10,6 +10,7 @@ import {
import type { Revalidate } from '../revalidate' import type { Revalidate } from '../revalidate'
import type { DeepReadonly } from '../../../shared/lib/deep-readonly' import type { DeepReadonly } from '../../../shared/lib/deep-readonly'
import { cacheScopeAsyncLocalStorage } from '../../async-storage/cache-scope'
import FetchCache from './fetch-cache' import FetchCache from './fetch-cache'
import FileSystemCache from './file-system-cache' import FileSystemCache from './file-system-cache'
import { normalizePagePath } from '../../../shared/lib/page-path/normalize-page-path' import { normalizePagePath } from '../../../shared/lib/page-path/normalize-page-path'
...@@ -76,6 +77,7 @@ export class IncrementalCache implements IncrementalCacheType { ...@@ -76,6 +77,7 @@ export class IncrementalCache implements IncrementalCacheType {
readonly fetchCacheKeyPrefix?: string readonly fetchCacheKeyPrefix?: string
readonly revalidatedTags?: string[] readonly revalidatedTags?: string[]
readonly isOnDemandRevalidate?: boolean readonly isOnDemandRevalidate?: boolean
readonly hasDynamicIO?: boolean
private readonly locks = new Map<string, Promise<void>>() private readonly locks = new Map<string, Promise<void>>()
private readonly unlocks = new Map<string, () => Promise<void>>() private readonly unlocks = new Map<string, () => Promise<void>>()
...@@ -89,6 +91,7 @@ export class IncrementalCache implements IncrementalCacheType { ...@@ -89,6 +91,7 @@ export class IncrementalCache implements IncrementalCacheType {
constructor({ constructor({
fs, fs,
dev, dev,
dynamicIO,
flushToDisk, flushToDisk,
fetchCache, fetchCache,
minimalMode, minimalMode,
...@@ -103,6 +106,7 @@ export class IncrementalCache implements IncrementalCacheType { ...@@ -103,6 +106,7 @@ export class IncrementalCache implements IncrementalCacheType {
}: { }: {
fs?: CacheFs fs?: CacheFs
dev: boolean dev: boolean
dynamicIO: boolean
fetchCache?: boolean fetchCache?: boolean
minimalMode?: boolean minimalMode?: boolean
serverDistDir?: string serverDistDir?: string
...@@ -143,6 +147,7 @@ export class IncrementalCache implements IncrementalCacheType { ...@@ -143,6 +147,7 @@ export class IncrementalCache implements IncrementalCacheType {
maxMemoryCacheSize = parseInt(process.env.__NEXT_TEST_MAX_ISR_CACHE, 10) maxMemoryCacheSize = parseInt(process.env.__NEXT_TEST_MAX_ISR_CACHE, 10)
} }
this.dev = dev this.dev = dev
this.hasDynamicIO = dynamicIO
this.disableForTestmode = process.env.NEXT_PRIVATE_TEST_PROXY === 'true' this.disableForTestmode = process.env.NEXT_PRIVATE_TEST_PROXY === 'true'
// this is a hack to avoid Webpack knowing this is equal to this.minimalMode // this is a hack to avoid Webpack knowing this is equal to this.minimalMode
// because we replace this.minimalMode to true in production bundles. // because we replace this.minimalMode to true in production bundles.
...@@ -404,6 +409,23 @@ export class IncrementalCache implements IncrementalCacheType { ...@@ -404,6 +409,23 @@ export class IncrementalCache implements IncrementalCacheType {
let entry: IncrementalCacheEntry | null = null let entry: IncrementalCacheEntry | null = null
let revalidate = ctx.revalidate let revalidate = ctx.revalidate
if (this.hasDynamicIO && ctx.kind === IncrementalCacheKind.FETCH) {
const cacheScope = cacheScopeAsyncLocalStorage.getStore()
if (cacheScope?.cache) {
const memoryCacheData = cacheScope.cache.get(cacheKey)
if (memoryCacheData?.kind === CachedRouteKind.FETCH) {
return {
isStale: false,
value: memoryCacheData,
revalidateAfter: false,
isFallback: false,
}
}
}
}
const cacheData = await this.cacheHandler?.get(cacheKey, ctx) const cacheData = await this.cacheHandler?.get(cacheKey, ctx)
if (cacheData?.value?.kind === CachedRouteKind.FETCH) { if (cacheData?.value?.kind === CachedRouteKind.FETCH) {
...@@ -502,6 +524,17 @@ export class IncrementalCache implements IncrementalCacheType { ...@@ -502,6 +524,17 @@ export class IncrementalCache implements IncrementalCacheType {
} }
) { ) {
if (this.disableForTestmode || (this.dev && !ctx.fetchCache)) return if (this.disableForTestmode || (this.dev && !ctx.fetchCache)) return
pathname = this._getPathname(pathname, ctx.fetchCache)
if (this.hasDynamicIO && data?.kind === CachedRouteKind.FETCH) {
const cacheScope = cacheScopeAsyncLocalStorage.getStore()
if (cacheScope?.cache) {
cacheScope.cache.set(pathname, data)
}
}
// FetchCache has upper limit of 2MB per-entry currently // FetchCache has upper limit of 2MB per-entry currently
const itemSize = JSON.stringify(data).length const itemSize = JSON.stringify(data).length
if ( if (
...@@ -519,8 +552,6 @@ export class IncrementalCache implements IncrementalCacheType { ...@@ -519,8 +552,6 @@ export class IncrementalCache implements IncrementalCacheType {
return return
} }
pathname = this._getPathname(pathname, ctx.fetchCache)
try { try {
// Set the value for the revalidate seconds so if it changes we can // Set the value for the revalidate seconds so if it changes we can
// update the cache with the new value. // update the cache with the new value.
......
import type { CacheScopeStore } from '../async-storage/cache-scope'
export class PrefetchCacheScopes {
private cacheScopes = new Map<
string,
{
cache: CacheScopeStore['cache']
// we track timestamp as we evict after 30s
// if a prefetch cache scope isn't used by then
timestamp: number
}
>()
private evict() {
for (const [key, value] of this.cacheScopes) {
if (value.timestamp < Date.now() - 30_000) {
this.cacheScopes.delete(key)
}
}
}
// TODO: should this key include query params if so we need to
// filter _rsc query
get(url: string) {
setImmediate(() => this.evict())
return this.cacheScopes.get(url)?.cache
}
set(url: string, cache: CacheScopeStore['cache']) {
setImmediate(() => this.evict())
return this.cacheScopes.set(url, {
cache,
timestamp: Date.now(),
})
}
del(url: string) {
this.cacheScopes.delete(url)
}
}
...@@ -371,6 +371,7 @@ export default class NextNodeServer extends BaseServer< ...@@ -371,6 +371,7 @@ export default class NextNodeServer extends BaseServer<
dev, dev,
requestHeaders, requestHeaders,
requestProtocol, requestProtocol,
dynamicIO: Boolean(this.nextConfig.experimental.dynamicIO),
allowedRevalidateHeaderKeys: allowedRevalidateHeaderKeys:
this.nextConfig.experimental.allowedRevalidateHeaderKeys, this.nextConfig.experimental.allowedRevalidateHeaderKeys,
minimalMode: this.minimalMode, minimalMode: this.minimalMode,
......
...@@ -126,7 +126,10 @@ export function cookies(): Promise<ReadonlyRequestCookies> { ...@@ -126,7 +126,10 @@ export function cookies(): Promise<ReadonlyRequestCookies> {
underlyingCookies = requestStore.cookies underlyingCookies = requestStore.cookies
} }
if (process.env.NODE_ENV === 'development') { if (
process.env.NODE_ENV === 'development' &&
!staticGenerationStore?.isPrefetchRequest
) {
return makeUntrackedExoticCookiesWithDevWarnings( return makeUntrackedExoticCookiesWithDevWarnings(
underlyingCookies, underlyingCookies,
staticGenerationStore?.route staticGenerationStore?.route
......
...@@ -34,9 +34,12 @@ export type UnsafeUnwrappedDraftMode = DraftMode ...@@ -34,9 +34,12 @@ export type UnsafeUnwrappedDraftMode = DraftMode
export function draftMode(): Promise<DraftMode> { export function draftMode(): Promise<DraftMode> {
const callingExpression = 'draftMode' const callingExpression = 'draftMode'
const requestStore = getExpectedRequestStore(callingExpression) const requestStore = getExpectedRequestStore(callingExpression)
const staticGenerationStore = staticGenerationAsyncStorage.getStore()
if (process.env.NODE_ENV === 'development') { if (
const staticGenerationStore = staticGenerationAsyncStorage.getStore() process.env.NODE_ENV === 'development' &&
!staticGenerationStore?.isPrefetchRequest
) {
const route = staticGenerationStore?.route const route = staticGenerationStore?.route
return createExoticDraftModeWithDevWarnings(requestStore.draftMode, route) return createExoticDraftModeWithDevWarnings(requestStore.draftMode, route)
} else { } else {
......
...@@ -112,7 +112,10 @@ export function headers(): Promise<ReadonlyHeaders> { ...@@ -112,7 +112,10 @@ export function headers(): Promise<ReadonlyHeaders> {
trackDynamicDataInDynamicRender(staticGenerationStore) trackDynamicDataInDynamicRender(staticGenerationStore)
} }
if (process.env.NODE_ENV === 'development') { if (
process.env.NODE_ENV === 'development' &&
!staticGenerationStore?.isPrefetchRequest
) {
return makeUntrackedExoticHeadersWithDevWarnings( return makeUntrackedExoticHeadersWithDevWarnings(
requestStore.headers, requestStore.headers,
staticGenerationStore?.route staticGenerationStore?.route
......
...@@ -161,7 +161,10 @@ function createRenderParams( ...@@ -161,7 +161,10 @@ function createRenderParams(
underlyingParams: Params, underlyingParams: Params,
staticGenerationStore: StaticGenerationStore staticGenerationStore: StaticGenerationStore
): Promise<Params> { ): Promise<Params> {
if (process.env.NODE_ENV === 'development') { if (
process.env.NODE_ENV === 'development' &&
!staticGenerationStore.isPrefetchRequest
) {
return makeDynamicallyTrackedExoticParamsWithDevWarnings( return makeDynamicallyTrackedExoticParamsWithDevWarnings(
underlyingParams, underlyingParams,
staticGenerationStore staticGenerationStore
......
...@@ -140,7 +140,10 @@ function createRenderSearchParams( ...@@ -140,7 +140,10 @@ function createRenderSearchParams(
// dictionary object. // dictionary object.
return Promise.resolve({}) return Promise.resolve({})
} else { } else {
if (process.env.NODE_ENV === 'development') { if (
process.env.NODE_ENV === 'development' &&
!staticGenerationStore.isPrefetchRequest
) {
return makeDynamicallyTrackedExoticSearchParamsWithDevWarnings( return makeDynamicallyTrackedExoticSearchParamsWithDevWarnings(
underlyingSearchParams, underlyingSearchParams,
staticGenerationStore staticGenerationStore
......
...@@ -80,6 +80,7 @@ export default class NextWebServer extends BaseServer< ...@@ -80,6 +80,7 @@ export default class NextWebServer extends BaseServer<
return new IncrementalCache({ return new IncrementalCache({
dev, dev,
requestHeaders, requestHeaders,
dynamicIO: Boolean(this.nextConfig.experimental.dynamicIO),
requestProtocol: 'https', requestProtocol: 'https',
allowedRevalidateHeaderKeys: allowedRevalidateHeaderKeys:
this.nextConfig.experimental.allowedRevalidateHeaderKeys, this.nextConfig.experimental.allowedRevalidateHeaderKeys,
......
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