{"version":3,"sources":["../../../src/server/use-cache/use-cache-wrapper.ts"],"sourcesContent":["import type { DeepReadonly } from '../../shared/lib/deep-readonly'\n/* eslint-disable import/no-extraneous-dependencies */\nimport {\n  renderToReadableStream,\n  decodeReply,\n  decodeReplyFromAsyncIterable,\n  createTemporaryReferenceSet as createServerTemporaryReferenceSet,\n} from 'react-server-dom-webpack/server'\nimport {\n  createFromReadableStream,\n  encodeReply,\n  createTemporaryReferenceSet as createClientTemporaryReferenceSet,\n} from 'react-server-dom-webpack/client'\nimport { prerender } from 'react-server-dom-webpack/static'\n/* eslint-enable import/no-extraneous-dependencies */\n\nimport type { WorkStore } from '../app-render/work-async-storage.external'\nimport { workAsyncStorage } from '../app-render/work-async-storage.external'\nimport type {\n  PrerenderStoreModernClient,\n  PrerenderStoreModernRuntime,\n  PrivateUseCacheStore,\n  RequestStore,\n  RevalidateStore,\n  UseCacheStore,\n  ValidationStoreClient,\n  WorkUnitStore,\n} from '../app-render/work-unit-async-storage.external'\nimport {\n  getHmrRefreshHash,\n  getResumeDataCache,\n  workUnitAsyncStorage,\n  getDraftModeProviderForCacheScope,\n  getCacheSignal,\n  isHmrRefresh,\n  getServerComponentsHmrCache,\n} from '../app-render/work-unit-async-storage.external'\n\nimport {\n  applyOwnerStack,\n  makeDevtoolsIOAwarePromise,\n  makeDynamicHangingPromise,\n  makeRuntimeHangingPromise,\n  makeStageHangingPromise,\n  makeUntrackedHangingPromise,\n  RENDER_STAGES_BY_DATA_KIND,\n} from '../dynamic-rendering-utils'\n\nimport type { ClientReferenceManifest } from '../../build/webpack/plugins/flight-manifest-plugin'\n\nimport {\n  getClientReferenceManifest,\n  getServerModuleMap,\n} from '../app-render/manifests-singleton'\nimport type { CacheEntry } from '../lib/cache-handlers/types'\nimport type { CacheSignal } from '../app-render/cache-signal'\nimport { decryptActionBoundArgs } from '../app-render/encryption'\nimport { InvariantError } from '../../shared/lib/invariant-error'\nimport {\n  createReactServerErrorHandler,\n  type DigestedError,\n} from '../app-render/create-error-handler'\nimport { createDigestWithErrorCode } from '../../lib/error-telemetry-utils'\nimport stringHash from 'next/dist/compiled/string-hash'\nimport {\n  MIN_PRERENDERABLE_EXPIRE,\n  MIN_PREFETCHABLE_STALE,\n  MIN_SHELL_STALE,\n} from './constants'\nimport { NEXT_CACHE_ROOT_PARAM_TAG_ID } from '../../lib/constants'\nimport {\n  getCacheHandler,\n  getDevTieredCacheHandler,\n  getPrivateCacheHandler,\n  isBuiltInCacheHandler,\n  isCustomCacheHandler,\n  isMemoryCacheDisabled,\n} from './handlers'\nimport type { CacheReadWriteHandler } from './tiered-cache-handler'\nimport { cloneCacheEntry } from './clone-cache-entry'\nimport { NEXT_INSTANT_TEST_COOKIE } from '../../client/components/app-router-headers'\nimport {\n  RequestCookiesAdapter,\n  type ReadonlyRequestCookies,\n} from '../web/spec-extension/adapters/request-cookies'\nimport {\n  HeadersAdapter,\n  type ReadonlyHeaders,\n} from '../web/spec-extension/adapters/headers'\nimport {\n  NestedDynamicUseCacheError,\n  UseCacheDeadlockError,\n  UseCacheTimeoutError,\n} from './use-cache-errors'\nimport {\n  createHangingInputAbortSignal,\n  postponeWithTracking,\n  throwToInterruptStaticGeneration,\n} from '../app-render/dynamic-rendering'\nimport {\n  makeErroringSearchParamsForUseCache,\n  type SearchParams,\n} from '../request/search-params'\nimport type { Params } from '../request/params'\nimport type { ResumeDataCache } from '../resume-data-cache/resume-data-cache'\nimport { createLazyResult, isResolvedLazyResult } from '../lib/lazy-result'\nimport { dynamicAccessAsyncStorage } from '../app-render/dynamic-access-async-storage.external'\nimport type { CacheLife } from './cache-life'\nimport {\n  RenderStage,\n  type AdvanceableRenderStage,\n} from '../app-render/staged-rendering'\nimport * as Log from '../../build/output/log'\nimport { getServerReact, getClientReact } from '../runtime-reacts.external'\nimport { createPromiseWithResolvers } from '../../shared/lib/promise-with-resolvers'\n\ninterface PrivateCacheContext {\n  readonly kind: 'private'\n  readonly outerWorkUnitStore:\n    | RequestStore\n    | PrivateUseCacheStore\n    | PrerenderStoreModernRuntime\n  readonly skipPropagation: boolean\n  readonly outerOwnerStack: string | undefined\n  /** The `'use cache'` function's server reference id (second arg of `cache()`). */\n  readonly functionId: string\n  /** The cache handler kind (first arg of `cache()`, e.g. 'default'). */\n  readonly handlerKind: string\n}\n\ninterface PublicCacheContext {\n  readonly kind: 'public'\n  // TODO: We should probably forbid nesting \"use cache\" inside unstable_cache.\n  readonly outerWorkUnitStore: Exclude<\n    WorkUnitStore,\n    PrerenderStoreModernClient | ValidationStoreClient\n  >\n  readonly skipPropagation: boolean\n  readonly outerOwnerStack: string | undefined\n  /** The `'use cache'` function's server reference id (second arg of `cache()`). */\n  readonly functionId: string\n  /** The cache handler kind (first arg of `cache()`, e.g. 'default'). */\n  readonly handlerKind: string\n  /**\n   * Eagerly captured at `cache()` entry, pointing at this invocation's call\n   * site. Only set when the outer is itself a public `'use cache'` (i.e. when\n   * this entry could become the propagated origin of a nested-dynamic cache\n   * error in the parent). When this cache resolves dynamic, this is copied into\n   * `outerWorkUnitStore.dynamicNestedCacheError` so the parent's error can use\n   * it as `cause`.\n   */\n  readonly dynamicNestedCacheError: Error | undefined\n}\n\ntype CacheContext = PrivateCacheContext | PublicCacheContext\n\nexport type CacheKeyParts =\n  | [buildId: string, id: string, args: unknown[]]\n  | [buildId: string, id: string, args: unknown[], hmrRefreshHash: string]\n\ninterface UseCachePageInnerProps {\n  params: Promise<Params>\n  searchParams?: Promise<SearchParams>\n}\n\nexport interface UseCachePageProps {\n  params: Promise<Params>\n  searchParams: Promise<SearchParams>\n  $$isPage: true\n}\n\nexport type UseCacheLayoutProps = {\n  params: Promise<Params>\n  $$isLayout: true\n} & {\n  // The value type should be React.ReactNode. But such an index signature would\n  // be incompatible with the other two props.\n  [slot: string]: any\n}\n\n/**\n * Cache entry metadata for propagation. Separated from the stream to make\n * ownership clear: metadata is freely shareable, streams must be explicitly\n * tee'd for each consumer.\n */\ninterface CacheResultMetadata {\n  readonly tags: string[]\n  readonly revalidate: number\n  readonly expire: number\n  readonly stale: number\n  readonly timestamp: number\n  readonly readRootParamNames: ReadonlySet<string> | undefined\n  readonly hasExplicitRevalidate: boolean | undefined\n  readonly hasExplicitExpire: boolean | undefined\n  readonly dynamicNestedCacheError: Error | undefined\n}\n\n/**\n * Encapsulates a pending cache invocation for deduping. Manages lazy stream\n * tee-ing (via fork()) and metadata access for both intra-request and\n * cross-request joiners.\n */\nclass SharedCacheEntry {\n  private stream: ReadableStream<Uint8Array>\n\n  /**\n   * The pending metadata promise. Cross-request joiners need to await this for\n   * root param verification BEFORE calling fork(). Intra-request joiners chain\n   * .then() for fire-and-forget propagation.\n   */\n  public readonly pendingMetadata: Promise<CacheResultMetadata>\n\n  constructor(\n    stream: ReadableStream<Uint8Array>,\n    pendingMetadata: Promise<CacheResultMetadata>\n  ) {\n    this.stream = stream\n    this.pendingMetadata = pendingMetadata\n  }\n\n  /**\n   * Tee the stream: returns a copy for the caller, replaces the internal stream\n   * with the remaining branch for future callers. Both the leader and joiners\n   * call this — everyone gets a fork.\n   */\n  fork(): ReadableStream<Uint8Array> {\n    const [forked, remaining] = this.stream.tee()\n    this.stream = remaining\n    return forked\n  }\n}\n\nexport type SharedCacheResult =\n  | {\n      readonly type: 'cached'\n      readonly entry: SharedCacheEntry\n    }\n  | {\n      readonly type: 'prerender-dynamic'\n      readonly hangingPromise: Promise<never>\n    }\n\nfunction ignoreReject() {}\n\n/**\n * Manages the deferred promise for a shared cache result, tracks which maps\n * it's registered in, and drives cleanup from resolve/reject.\n *\n * For 'cached' results, cleanup is lazy: entries stay in the maps until\n * metadata/collection resolves, giving late-arriving invocations a chance to\n * join while the leader streams. For 'prerender-dynamic' and errors, cleanup\n * is immediate.\n */\nclass ResolvableSharedCacheResult {\n  private readonly deferred = createPromiseWithResolvers<SharedCacheResult>()\n\n  private readonly registrations: Array<{\n    map: Map<string, Promise<SharedCacheResult>>\n    key: string\n    /**\n     * Where to move the entry once the invocation completes, instead of\n     * dropping it. Only set for the request-scoped map, and only for kinds\n     * whose entries are worth retaining; the module-scope cross-request map\n     * must never retain, since its entries would outlive the request that\n     * produced them.\n     */\n    retentionMap?: Map<string, Promise<SharedCacheResult>>\n  }> = []\n\n  registerIn(\n    map: Map<string, Promise<SharedCacheResult>>,\n    key: string,\n    retentionMap?: Map<string, Promise<SharedCacheResult>>\n  ): void {\n    map.set(key, this.deferred.promise)\n    this.registrations.push({ map, key, retentionMap })\n  }\n\n  resolve(result: SharedCacheResult): void {\n    this.deferred.resolve(result)\n    if (result.type === 'cached') {\n      // Retain only an entry that collected successfully. A failed collection\n      // leaves metadata a later invocation cannot read, so it is dropped like\n      // any other failure and the next invocation regenerates.\n      result.entry.pendingMetadata.then(\n        () => this.cleanupAndRetain(),\n        () => this.cleanup()\n      )\n    } else {\n      this.cleanup()\n    }\n  }\n\n  reject(error: unknown): void {\n    // The promise stored in the dedup maps has no consumer unless a concurrent\n    // invocation joined it, so we attach a noop catch handler to prevent the\n    // rejection from being reported as unhandled. The leader rethrows the\n    // error into the render, which is where it's surfaced.\n    this.deferred.promise.catch(ignoreReject)\n    this.deferred.reject(error)\n    this.cleanup()\n  }\n\n  /**\n   * Drops the pending registrations, leaving nothing for a later invocation to\n   * join. Used when the invocation produced no entry that a later one could\n   * serve: an error has no value, and a 'prerender-dynamic' result is a hanging\n   * promise bound to the leader's render signal.\n   */\n  private cleanup(): void {\n    for (const { map, key } of this.registrations) {\n      map.delete(key)\n    }\n  }\n\n  /**\n   * Drops the pending registrations and moves the entry into the retention map\n   * where one was given, so a later invocation in the same request can reuse it\n   * instead of repeating the lookup and, on a miss, the work.\n   */\n  private cleanupAndRetain(): void {\n    for (const { map, key, retentionMap } of this.registrations) {\n      map.delete(key)\n      retentionMap?.set(key, this.deferred.promise)\n    }\n  }\n}\n\n/**\n * Module-scope map for cross-request deduplication. Keyed by `cacheHandlerKey`\n * (specific key on warm path, coarse key on cold path). Entries live only for\n * the duration of the leader's invocation.\n */\nconst crossRequestPendingCacheInvocations = new Map<\n  string,\n  Promise<SharedCacheResult>\n>()\n\nconst isEdgeRuntime = process.env.NEXT_RUNTIME === 'edge'\n\nconst debug = process.env.NEXT_PRIVATE_DEBUG_CACHE\n  ? console.debug.bind(console, 'use-cache:')\n  : undefined\n\nconst filterStackFrame =\n  process.env.NODE_ENV !== 'production'\n    ? (require('../lib/source-maps') as typeof import('../lib/source-maps'))\n        .filterStackFrameDEV\n    : undefined\nconst findSourceMapURL =\n  process.env.NODE_ENV !== 'production'\n    ? (require('../lib/source-maps') as typeof import('../lib/source-maps'))\n        .findSourceMapURLDEV\n    : undefined\n\nconst nestedCacheZeroRevalidateErrorMessage =\n  `A \"use cache\" with zero \\`revalidate\\` is nested inside another \"use cache\" ` +\n  `that has no explicit \\`cacheLife\\`, which is not allowed during ` +\n  `prerendering. Add \\`cacheLife()\\` to the outer \"use cache\" to choose ` +\n  `whether it should be prerendered (with non-zero \\`revalidate\\`) or remain ` +\n  `dynamic (with zero \\`revalidate\\`). Read more: ` +\n  `https://nextjs.org/docs/messages/nested-use-cache-no-explicit-cachelife`\n\nconst nestedCacheShortExpireErrorMessage =\n  `A \"use cache\" with short \\`expire\\` (under 5 minutes) is nested inside ` +\n  `another \"use cache\" that has no explicit \\`cacheLife\\`, which is not ` +\n  `allowed during prerendering. Add \\`cacheLife()\\` to the outer \"use cache\" ` +\n  `to choose whether it should be prerendered (with longer \\`expire\\`) or remain ` +\n  `dynamic (with short \\`expire\\`). Read more: ` +\n  `https://nextjs.org/docs/messages/nested-use-cache-no-explicit-cachelife`\n\n// Tracks which root params each cache function has historically read. Used to\n// compute the specific cache key upfront on subsequent invocations. In-memory\n// only — after server restart, the coarse-key redirect entry in the cache\n// handler provides fallback.\nconst knownRootParamsByFunctionId = new Map<string, Set<string>>()\n\nfunction addKnownRootParamNames(\n  id: string,\n  names: ReadonlySet<string>\n): Set<string> {\n  const existing = knownRootParamsByFunctionId.get(id)\n  if (existing) {\n    for (const name of names) {\n      existing.add(name)\n    }\n    return existing\n  }\n  const created = new Set(names)\n  knownRootParamsByFunctionId.set(id, created)\n  return created\n}\n\nfunction computeRootParamsCacheKeySuffix(\n  rootParams: Params,\n  paramNames: ReadonlySet<string>\n): string {\n  if (paramNames.size === 0) {\n    return ''\n  }\n\n  return JSON.stringify(\n    [...paramNames]\n      .sort()\n      .map((paramName) => [paramName, rootParams[paramName]])\n  )\n}\n\n// Next-internal cookies that must not vary the private cache key, since they're\n// not part of the application's own cookie state. The instant-navigation cookie\n// toggles while a navigation lock is held, so including it would force spurious\n// misses.\nconst COOKIES_EXCLUDED_FROM_PRIVATE_CACHE_KEY = new Set<string>([\n  NEXT_INSTANT_TEST_COOKIE,\n])\n\n// Request and transport headers that must not vary the private cache key. They\n// either differ between otherwise-equivalent requests, which would cause\n// spurious misses (a browser reload adds `cache-control`/`pragma` that an\n// initial navigation doesn't, and `accept`/`sec-fetch-*` differ between an HTML\n// navigation and an RSC or prefetch request for the same page), or are\n// connection- and proxy-level rather than application data. The `cookie` header\n// is excluded because cookies are keyed separately below (via the dedicated\n// cookie path, which applies `COOKIES_EXCLUDED_FROM_PRIVATE_CACHE_KEY`);\n// including the raw header would duplicate them and reintroduce the cookies\n// that path excludes. Header names are lowercased by `HeadersAdapter`, so every\n// entry here is lowercase.\nconst HEADERS_EXCLUDED_FROM_PRIVATE_CACHE_KEY = new Set<string>([\n  'accept',\n  'accept-encoding',\n  'cache-control',\n  'connection',\n  'cookie',\n  'if-match',\n  'if-modified-since',\n  'if-none-match',\n  'if-range',\n  'if-unmodified-since',\n  'keep-alive',\n  'pragma',\n  'priority',\n  'purpose',\n  'range',\n  'sec-fetch-dest',\n  'sec-fetch-mode',\n  'sec-fetch-site',\n  'sec-fetch-user',\n  'sec-purpose',\n  'te',\n  'upgrade',\n  'upgrade-insecure-requests',\n  'x-forwarded-for',\n  'x-forwarded-host',\n  'x-forwarded-port',\n  'x-forwarded-proto',\n])\n\n// TODO: This varies the dev private cache key by the request's cookies and\n// headers (minus the transport and content-negotiation headers excluded above).\n// It's a heuristic: it still over-keys (a cache that reads only one cookie or\n// header varies by all of them) and the header denylist is necessarily\n// incomplete. Follow up by tracking which cookies and headers a cache function\n// actually reads (the same mechanism root params use via `readRootParamNames`)\n// and keying by only those. Note that Next-internal flight headers such as\n// `rsc` and `next-router-state-tree` are already stripped upstream in\n// `getHeaders`, so they never appear here.\nfunction computePrivateCacheKeyRequestSuffix(\n  cookies: ReadonlyRequestCookies,\n  headers: ReadonlyHeaders\n): string {\n  const relevantCookies = cookies\n    .getAll()\n    .filter(\n      (cookie) => !COOKIES_EXCLUDED_FROM_PRIVATE_CACHE_KEY.has(cookie.name)\n    )\n    .map((cookie): [string, string] => [cookie.name, cookie.value])\n    .sort(([nameA], [nameB]) => (nameA < nameB ? -1 : nameA > nameB ? 1 : 0))\n\n  const relevantHeaders = [...headers.entries()]\n    .filter(([name]) => !HEADERS_EXCLUDED_FROM_PRIVATE_CACHE_KEY.has(name))\n    .sort(([nameA], [nameB]) => (nameA < nameB ? -1 : nameA > nameB ? 1 : 0))\n\n  if (relevantCookies.length === 0 && relevantHeaders.length === 0) {\n    return ''\n  }\n\n  return JSON.stringify({ cookies: relevantCookies, headers: relevantHeaders })\n}\n\nfunction saveToResumeDataCache(\n  resumeDataCache: ResumeDataCache | null,\n  serializedCacheKey: string,\n  pendingCacheResult: Promise<CollectedCacheResult>\n): Promise<CollectedCacheResult> {\n  if (!resumeDataCache?.mutable) {\n    return pendingCacheResult\n  }\n\n  const split = clonePendingCacheResult(pendingCacheResult)\n  const savedCacheResult = getNthCacheResult(split, 0)\n  const rdcResult = getNthCacheResult(split, 1)\n\n  // The RDC is per-page and root params are fixed within a page, so we always\n  // use the coarse key (without root param suffix). Unlike the cache handler,\n  // the RDC doesn't need root-param-specific keys for isolation.\n  resumeDataCache.cache.set(serializedCacheKey, rdcResult)\n  debug?.('Resume Data Cache entry saved', serializedCacheKey)\n\n  return savedCacheResult\n}\n\n/**\n * A joiner's RDC context may differ from the leader's:\n *\n * - Intra-request: the leader was nested inside another cache (no accessible\n *   RDC) while this joiner is top-level and has one.\n * - Cross-request: the leader belongs to a different request entirely — this\n *   request's RDC has never seen the entry.\n *\n * In both cases the joiner must save to its own RDC so its final prerender can\n * resume from the entry. Constructs a `CollectedCacheResult` from a forked\n * stream branch of the shared entry and the awaited metadata.\n *\n * The `cache.has()` guard avoids redundant saves when the intra-request leader\n * already saved to the same RDC. Without it, this would needlessly tee the\n * stream and overwrite an equivalent RDC entry.\n */\nfunction saveSharedCacheEntryToResumeDataCache(\n  serializedCacheKey: string,\n  sharedCacheEntry: SharedCacheEntry,\n  resumeDataCache: ResumeDataCache | null\n): void {\n  if (\n    !resumeDataCache?.mutable ||\n    resumeDataCache.cache.has(serializedCacheKey)\n  ) {\n    return\n  }\n\n  const rdcResult: Promise<CollectedCacheResult> =\n    sharedCacheEntry.pendingMetadata.then((metadata) => ({\n      entry: {\n        value: sharedCacheEntry.fork(),\n        tags: metadata.tags,\n        revalidate: metadata.revalidate,\n        expire: metadata.expire,\n        stale: metadata.stale,\n        timestamp: metadata.timestamp,\n      },\n      readRootParamNames: metadata.readRootParamNames,\n      hasExplicitRevalidate: metadata.hasExplicitRevalidate,\n      hasExplicitExpire: metadata.hasExplicitExpire,\n      dynamicNestedCacheError: metadata.dynamicNestedCacheError,\n    }))\n\n  resumeDataCache.cache.set(serializedCacheKey, rdcResult)\n  debug?.('Resume Data Cache entry saved by joiner', serializedCacheKey)\n}\n\n/**\n * Completes a join onto another invocation's entry, whether that invocation is\n * still filling or has already finished: forks the stream, saves to this\n * invocation's RDC if the leader had none, and balances the cache signal read\n * once the entry is fully collected.\n */\nfunction serveJoinedCacheEntry(\n  sharedCacheEntry: SharedCacheEntry,\n  serializedCacheKey: string,\n  resumeDataCache: ResumeDataCache | null,\n  cacheContext: CacheContext,\n  cacheSignal: CacheSignal | null\n): ReadableStream<Uint8Array> {\n  const stream = sharedCacheEntry.fork()\n\n  // If the leader was nested inside another cache (no accessible RDC), it\n  // couldn't save to the RDC. This joiner may be top-level with an RDC, in\n  // which case it must save here; otherwise the RDC lookup during the final\n  // prerender will miss.\n  saveSharedCacheEntryToResumeDataCache(\n    serializedCacheKey,\n    sharedCacheEntry,\n    resumeDataCache\n  )\n\n  // End the cache signal read when the result is fully collected, not when the\n  // stream is available. A failed collection has no metadata to propagate but\n  // must still balance the read, so both settlements end it; leaving it open\n  // would stall a prerender waiting for its cache reads. The trailing .catch()\n  // covers propagation itself throwing after the rendering stream resolved.\n  sharedCacheEntry.pendingMetadata\n    .then(\n      (metadata) => {\n        cacheSignal?.endRead()\n        maybePropagateCacheEntryMetadata(cacheContext, metadata)\n      },\n      () => {\n        cacheSignal?.endRead()\n      }\n    )\n    .catch(() => {})\n\n  return stream\n}\n\nfunction saveToCacheHandler(\n  cacheHandler: CacheReadWriteHandler,\n  workStore: WorkStore,\n  id: string,\n  cacheHandlerKeyBase: string,\n  savedCacheResult: Promise<CollectedCacheResult>,\n  rootParams: Params | undefined\n): Promise<CollectedCacheResult> {\n  // Write the entry to the cache handler. With root params, this is a redirect\n  // entry at the coarse key plus the actual entry at the specific key;\n  // otherwise just the entry at the coarse key. Both set calls are fired\n  // together and awaited in parallel.\n  const combinedSetPromise = savedCacheResult.then(async (collectedResult) => {\n    const { entry: fullEntry, readRootParamNames } = collectedResult\n\n    // Use the combined set (union of all historically observed reads) for both\n    // the specific key and the redirect entry's tags. The read path computes\n    // cacheHandlerKey from this same union (knownRootParamsByFunctionId), so\n    // the write path must use the identical set to land on the same specific\n    // key. If we used only the current invocation's reads, a function that\n    // conditionally reads different root params across invocations would\n    // scatter entries across different specific keys, making previous entries\n    // unreachable from the read path's union-based lookup.\n    const rootParamNames = readRootParamNames\n      ? addKnownRootParamNames(id, readRootParamNames)\n      : knownRootParamsByFunctionId.get(id)\n\n    const setPromises: Promise<void>[] = []\n    let coarseEntry: CacheEntry = fullEntry\n\n    if (rootParamNames && rootParamNames.size > 0 && rootParams) {\n      const specificKey =\n        cacheHandlerKeyBase +\n        computeRootParamsCacheKeySuffix(rootParams, rootParamNames)\n\n      setPromises.push(\n        cacheHandler.set(specificKey, Promise.resolve(fullEntry))\n      )\n\n      // The coarse key gets a redirect entry instead. On a cold server (empty\n      // knownRootParamsByFunctionId), its tags tell a reader which root params\n      // to include in the specific-key lookup.\n      const rootParamTags = [...rootParamNames].map(\n        (paramName) => NEXT_CACHE_ROOT_PARAM_TAG_ID + paramName\n      )\n\n      coarseEntry = {\n        value: new ReadableStream({\n          start(controller) {\n            // Single byte so the entry has non-zero size in LRU caches.\n            controller.enqueue(new Uint8Array([0]))\n            controller.close()\n          },\n        }),\n        tags: [...fullEntry.tags, ...rootParamTags],\n        stale: fullEntry.stale,\n        timestamp: fullEntry.timestamp,\n        expire: fullEntry.expire,\n        revalidate: fullEntry.revalidate,\n      } satisfies CacheEntry\n    }\n\n    setPromises.push(\n      cacheHandler.set(cacheHandlerKeyBase, Promise.resolve(coarseEntry))\n    )\n\n    await Promise.all(setPromises)\n  })\n\n  workStore.pendingRevalidateWrites ??= []\n  workStore.pendingRevalidateWrites.push(combinedSetPromise)\n\n  // A cross-request joiner reads its recomputed specific key only after it has\n  // awaited this entry's metadata, so gate the metadata on the writes landing:\n  // that guarantees the entry is present when the joiner re-reads. A failed\n  // write shouldn't reject the metadata (the joiner just misses and\n  // regenerates), so settle either way; a collection failure still propagates\n  // through `savedCacheResult`.\n  return combinedSetPromise.then(\n    () => savedCacheResult,\n    () => savedCacheResult\n  )\n}\n\nfunction generateCacheEntry(\n  workStore: WorkStore,\n  cacheContext: CacheContext,\n  clientReferenceManifest: DeepReadonly<ClientReferenceManifest>,\n  encodedArguments: FormData | string,\n  fn: (...args: unknown[]) => Promise<unknown>,\n  timeoutError: UseCacheTimeoutError,\n  deadlockError: UseCacheDeadlockError | undefined\n) {\n  // We need to run this inside a clean AsyncLocalStorage snapshot so that the cache\n  // generation cannot read anything from the context we're currently executing which\n  // might include request specific things like cookies() inside a React.cache().\n  // Note: It is important that we await at least once before this because it lets us\n  // pop out of any stack specific contexts as well - aka \"Sync\" Local Storage.\n  return workStore.runInCleanSnapshot(\n    generateCacheEntryWithRestoredWorkStore,\n    workStore,\n    cacheContext,\n    clientReferenceManifest,\n    encodedArguments,\n    fn,\n    timeoutError,\n    deadlockError\n  )\n}\n\nfunction generateCacheEntryWithRestoredWorkStore(\n  workStore: WorkStore,\n  cacheContext: CacheContext,\n  clientReferenceManifest: DeepReadonly<ClientReferenceManifest>,\n  encodedArguments: FormData | string,\n  fn: (...args: unknown[]) => Promise<unknown>,\n  timeoutError: UseCacheTimeoutError,\n  deadlockError: UseCacheDeadlockError | undefined\n) {\n  // Since we cleared the AsyncLocalStorage we need to restore the workStore.\n  // Note: We explicitly don't restore the RequestStore nor the PrerenderStore.\n  // We don't want any request specific information leaking an we don't want to create a\n  // bloated fake request mock for every cache call. So any feature that currently lives\n  // in RequestStore but should be available to Caches need to move to WorkStore.\n  // PrerenderStore is not needed inside the cache scope because the outer most one will\n  // be the one to report its result to the outer Prerender.\n  return workAsyncStorage.run(\n    workStore,\n    generateCacheEntryWithCacheContext,\n    workStore,\n    cacheContext,\n    clientReferenceManifest,\n    encodedArguments,\n    fn,\n    timeoutError,\n    deadlockError\n  )\n}\n\nfunction createUseCacheStore(\n  workStore: WorkStore,\n  cacheContext: CacheContext,\n  defaultCacheLife: Required<CacheLife>\n): UseCacheStore {\n  if (cacheContext.kind === 'private') {\n    const outerWorkUnitStore = cacheContext.outerWorkUnitStore\n\n    return {\n      type: 'private-cache',\n      phase: 'render',\n      implicitTags: outerWorkUnitStore?.implicitTags,\n      revalidate: defaultCacheLife.revalidate,\n      expire: defaultCacheLife.expire,\n      stale: defaultCacheLife.stale,\n      explicitRevalidate: undefined,\n      explicitExpire: undefined,\n      explicitStale: undefined,\n      tags: null,\n      hmrRefreshHash: getHmrRefreshHash(outerWorkUnitStore),\n      isHmrRefresh: isHmrRefresh(outerWorkUnitStore),\n      serverComponentsHmrCache: getServerComponentsHmrCache(outerWorkUnitStore),\n      forceRevalidate: shouldForceRevalidate(workStore, outerWorkUnitStore),\n      draftMode: getDraftModeProviderForCacheScope(\n        workStore,\n        outerWorkUnitStore\n      ),\n      rootParams: outerWorkUnitStore.rootParams,\n      readRootParamNames: process.env.__NEXT_DEV_SERVER ? new Set() : undefined,\n      // Every private cache scope is its own work unit. Any cache keyed on\n      // headers() or cookies() needs to be invalidated. Otherwise some\n      // Next.js API semantics leak across render passes.\n      headers: HeadersAdapter.fresh(outerWorkUnitStore.headers),\n      cookies: RequestCookiesAdapter.fresh(outerWorkUnitStore.cookies),\n      outerOwnerStack: cacheContext.outerOwnerStack,\n    }\n  } else {\n    let useCacheOrRequestStore: RequestStore | UseCacheStore | undefined\n    const outerWorkUnitStore = cacheContext.outerWorkUnitStore\n\n    switch (outerWorkUnitStore.type) {\n      case 'cache':\n      case 'private-cache':\n      case 'request':\n        useCacheOrRequestStore = outerWorkUnitStore\n        break\n      case 'prerender-runtime':\n      case 'prerender':\n      case 'prerender-ppr':\n      case 'prerender-legacy':\n      case 'unstable-cache':\n      case 'generate-static-params':\n        break\n      default:\n        outerWorkUnitStore satisfies never\n    }\n\n    return {\n      type: 'cache',\n      phase: 'render',\n      implicitTags: outerWorkUnitStore.implicitTags,\n      revalidate: defaultCacheLife.revalidate,\n      expire: defaultCacheLife.expire,\n      stale: defaultCacheLife.stale,\n      explicitRevalidate: undefined,\n      explicitExpire: undefined,\n      explicitStale: undefined,\n      tags: null,\n      hmrRefreshHash: getHmrRefreshHash(outerWorkUnitStore),\n      isHmrRefresh: useCacheOrRequestStore?.isHmrRefresh ?? false,\n      serverComponentsHmrCache:\n        useCacheOrRequestStore?.serverComponentsHmrCache,\n      forceRevalidate: shouldForceRevalidate(workStore, outerWorkUnitStore),\n      draftMode: getDraftModeProviderForCacheScope(\n        workStore,\n        outerWorkUnitStore\n      ),\n      rootParams: outerWorkUnitStore.rootParams,\n      readRootParamNames: new Set<string>(),\n      outerOwnerStack: cacheContext.outerOwnerStack,\n      dynamicNestedCacheError: undefined,\n    }\n  }\n}\n\n/**\n * Captures the owner stack from the outer component tree before entering a\n * cache boundary. When nested inside another cache scope, the parent's\n * outerOwnerStack is concatenated so that the full component tree is preserved\n * across multiple cache boundaries.\n */\nfunction captureOuterOwnerStack(\n  workUnitStore: WorkUnitStore\n): string | undefined {\n  const capturedOwnerStack =\n    (getClientReact()?.captureOwnerStack?.() ??\n      getServerReact()?.captureOwnerStack?.()) ||\n    ''\n\n  let parentOuterOwnerStack: string | undefined\n  switch (workUnitStore.type) {\n    case 'cache':\n    case 'private-cache':\n      parentOuterOwnerStack = workUnitStore.outerOwnerStack\n      break\n    case 'unstable-cache':\n    case 'request':\n    case 'prerender':\n    case 'prerender-ppr':\n    case 'prerender-legacy':\n    case 'prerender-runtime':\n    case 'prerender-client':\n    case 'validation-client':\n    case 'generate-static-params':\n      break\n    default:\n      workUnitStore satisfies never\n  }\n\n  return capturedOwnerStack + (parentOuterOwnerStack || '') || undefined\n}\n\n// The maximum time we allow a `'use cache'` entry to fill. After this, we\n// assume the fill is stalled — either on hanging input to the cached function,\n// or on hanging I/O inside of it — and de-opt with an error.\n//\n// For prerender, the effective value is clamped to 90% of the configured\n// `staticPageGenerationTimeout` so the cache-fill error surfaces before the\n// build worker kills the page. In dev (`request`), the configured\n// `experimental.useCacheTimeout` is used straight.\nfunction getUseCacheFillTimeoutMs(\n  workStore: WorkStore,\n  workUnitStoreType: 'prerender' | 'prerender-runtime' | 'request'\n): number {\n  const { useCacheTimeout, staticPageGenerationTimeout } = workStore\n\n  const effectiveTimeout =\n    workUnitStoreType === 'request'\n      ? useCacheTimeout\n      : Math.min(useCacheTimeout, staticPageGenerationTimeout * 0.9)\n\n  return effectiveTimeout * 1000\n}\n\nfunction generateCacheEntryWithCacheContext(\n  workStore: WorkStore,\n  cacheContext: CacheContext,\n  clientReferenceManifest: DeepReadonly<ClientReferenceManifest>,\n  encodedArguments: FormData | string,\n  fn: (...args: unknown[]) => Promise<unknown>,\n  timeoutError: UseCacheTimeoutError,\n  deadlockError: UseCacheDeadlockError | undefined\n) {\n  const defaultCacheLife = workStore.cacheLifeProfiles.default\n\n  // Initialize the Store for this Cache entry.\n  const cacheStore = createUseCacheStore(\n    workStore,\n    cacheContext,\n    defaultCacheLife\n  )\n\n  return workUnitAsyncStorage.run(cacheStore, () =>\n    dynamicAccessAsyncStorage.run(\n      { abortController: new AbortController() },\n      generateCacheEntryImpl,\n      workStore,\n      cacheContext,\n      cacheStore,\n      clientReferenceManifest,\n      encodedArguments,\n      fn,\n      timeoutError,\n      deadlockError\n    )\n  )\n}\n\nfunction propagateCacheLifeAndTagsToRevalidateStore(\n  revalidateStore: RevalidateStore,\n  metadata: CacheResultMetadata\n): void {\n  const outerTags = (revalidateStore.tags ??= [])\n\n  for (const tag of metadata.tags) {\n    if (!outerTags.includes(tag)) {\n      outerTags.push(tag)\n    }\n  }\n\n  if (revalidateStore.stale > metadata.stale) {\n    revalidateStore.stale = metadata.stale\n  }\n\n  if (revalidateStore.revalidate > metadata.revalidate) {\n    revalidateStore.revalidate = metadata.revalidate\n  }\n\n  if (revalidateStore.expire > metadata.expire) {\n    revalidateStore.expire = metadata.expire\n  }\n}\n\nfunction propagateCacheStaleTimeToRequestStore(\n  requestStore: RequestStore,\n  metadata: CacheResultMetadata\n): void {\n  if (requestStore.stale !== undefined && requestStore.stale > metadata.stale) {\n    requestStore.stale = metadata.stale\n  }\n}\n\nfunction propagateCacheEntryMetadata(\n  cacheContext: CacheContext,\n  metadata: CacheResultMetadata\n): void {\n  if (cacheContext.kind === 'private') {\n    switch (cacheContext.outerWorkUnitStore.type) {\n      case 'prerender-runtime':\n      case 'private-cache':\n        propagateCacheLifeAndTagsToRevalidateStore(\n          cacheContext.outerWorkUnitStore,\n          metadata\n        )\n        break\n      case 'request':\n        propagateCacheStaleTimeToRequestStore(\n          cacheContext.outerWorkUnitStore,\n          metadata\n        )\n        break\n      case undefined:\n        break\n      default:\n        cacheContext.outerWorkUnitStore satisfies never\n    }\n  } else {\n    switch (cacheContext.outerWorkUnitStore.type) {\n      case 'cache':\n        if (metadata.readRootParamNames) {\n          for (const paramName of metadata.readRootParamNames) {\n            cacheContext.outerWorkUnitStore.readRootParamNames.add(paramName)\n          }\n        }\n        // If this entry's cache life is dynamic, record this invocation as the\n        // origin to use as `cause` when the outer cache surfaces the\n        // nested-dynamic cache error. `??=` keeps the first occurrence so the\n        // cause points at the immediate dynamic child.\n        if (\n          cacheContext.dynamicNestedCacheError !== undefined &&\n          (metadata.revalidate === 0 ||\n            metadata.expire < MIN_PRERENDERABLE_EXPIRE)\n        ) {\n          cacheContext.outerWorkUnitStore.dynamicNestedCacheError ??=\n            cacheContext.dynamicNestedCacheError\n        }\n      // fallthrough\n      case 'private-cache':\n      case 'prerender':\n      case 'prerender-runtime':\n      case 'prerender-ppr':\n      case 'prerender-legacy':\n        propagateCacheLifeAndTagsToRevalidateStore(\n          cacheContext.outerWorkUnitStore,\n          metadata\n        )\n        break\n      case 'request':\n        propagateCacheStaleTimeToRequestStore(\n          cacheContext.outerWorkUnitStore,\n          metadata\n        )\n        break\n      case 'unstable-cache':\n      case 'generate-static-params':\n        break\n      default:\n        cacheContext.outerWorkUnitStore satisfies never\n    }\n  }\n}\n\n/**\n * Conditionally propagates cache life, tags, and root param names to the outer\n * context. During prerenders (`prerender` / `prerender-runtime`) and dev\n * cache-filling requests, propagation is deferred because the entry might be\n * omitted from the final prerender due to short expire/stale times. If omitted,\n * it should not affect the prerender. The final decision happens when the entry\n * is read from the resume data cache in the final render phase — at that point\n * `propagateCacheEntryMetadata` is called unconditionally (after the omission\n * checks have already filtered out short-lived entries).\n *\n * Note: Root param names are only propagated when the outer context is a\n * `cache` store (i.e. an enclosing `\"use cache\"` function), which is never\n * deferred. For prerender contexts, root param names are tracked separately\n * via `addKnownRootParamNames` in the resume data cache read path.\n */\nfunction maybePropagateCacheEntryMetadata(\n  cacheContext: CacheContext,\n  metadata: CacheResultMetadata\n): void {\n  const outerWorkUnitStore = cacheContext.outerWorkUnitStore\n\n  switch (outerWorkUnitStore.type) {\n    case 'prerender':\n    case 'prerender-runtime': {\n      // Don't propagate yet — the entry might be omitted from the final\n      // prerender due to short expire/stale times. Propagation will happen when\n      // the entry is read from the resume data cache.\n      break\n    }\n    case 'request': {\n      if (\n        process.env.NODE_ENV === 'development' &&\n        outerWorkUnitStore.cacheSignal\n      ) {\n        // If we're filling caches for a dev request, apply the same logic as\n        // prerenders do above.\n        break\n      }\n      // fallthrough\n    }\n    case 'private-cache':\n    case 'cache':\n    case 'unstable-cache':\n    case 'prerender-legacy':\n    case 'prerender-ppr': {\n      propagateCacheEntryMetadata(cacheContext, metadata)\n      break\n    }\n    case 'generate-static-params':\n      break\n    default: {\n      outerWorkUnitStore satisfies never\n    }\n  }\n}\n\nexport interface CollectedCacheResult {\n  entry: CacheEntry\n  /**\n   * Whether the revalidate value was explicitly set via `cacheLife()`.\n   * - `true`: explicitly set\n   * - `false`: implicit (propagated from a nested cache or implicitly using the\n   *   default profile)\n   * - `undefined`: unknown (e.g. pre-existing entry from a cache handler)\n   */\n  hasExplicitRevalidate: boolean | undefined\n  /**\n   * Whether the expire value was explicitly set via `cacheLife()`.\n   * - `true`: explicitly set\n   * - `false`: implicit (propagated from a nested cache or implicitly using the\n   *   default profile)\n   * - `undefined`: unknown (e.g. pre-existing entry from a cache handler)\n   */\n  hasExplicitExpire: boolean | undefined\n  /**\n   * The root param names that were read during cache entry generation.\n   * Used to compute the specific cache key after generation completes.\n   * `undefined` for pre-existing entries from cache handlers where we\n   * don't have this information.\n   */\n  readRootParamNames: ReadonlySet<string> | undefined\n  /**\n   * The `Error` carried up from the first nested public `'use cache'`\n   * invocation that propagated a dynamic cache life into this entry, captured\n   * eagerly at that inner invocation's `cache()` entry. Used as `cause` for the\n   * nested-dynamic cache error so the redbox can point at the inner invocation\n   * site, not just the outer one. Lives in-memory only — intentionally dropped\n   * from the serialized RDC because dynamic entries aren't serialized either.\n   */\n  dynamicNestedCacheError: Error | undefined\n}\n\nasync function collectResult(\n  savedStream: ReadableStream<Uint8Array>,\n  workStore: WorkStore,\n  cacheContext: CacheContext,\n  innerCacheStore: UseCacheStore,\n  startTime: number,\n  errors: Array<unknown> // This is a live array that gets pushed into.\n): Promise<CollectedCacheResult> {\n  // We create a buffered stream that collects all chunks until the end to\n  // ensure that RSC has finished rendering and therefore we have collected\n  // all tags. In the future the RSC API might allow for the equivalent of\n  // the allReady Promise that exists on SSR streams.\n  //\n  // If something errored or rejected anywhere in the render, we close\n  // the stream as errored. This lets a CacheHandler choose to save the\n  // partial result up until that point for future hits for a while to avoid\n  // unnecessary retries or not to retry. We use the end of the stream for\n  // this to avoid another complicated side-channel. A receiver has to consider\n  // that the stream might also error for other reasons anyway such as losing\n  // connection.\n\n  const buffer: Uint8Array[] = []\n  const reader = savedStream.getReader()\n\n  try {\n    for (let entry; !(entry = await reader.read()).done; ) {\n      buffer.push(entry.value)\n    }\n  } catch (error) {\n    errors.push(error)\n  }\n\n  let idx = 0\n  const bufferStream = new ReadableStream<Uint8Array>({\n    pull(controller) {\n      if (workStore.invalidDynamicUsageError) {\n        controller.error(workStore.invalidDynamicUsageError)\n      } else if (idx < buffer.length) {\n        controller.enqueue(buffer[idx++])\n      } else if (errors.length > 0) {\n        // TODO: Should we use AggregateError here?\n        controller.error(errors[0])\n      } else {\n        controller.close()\n      }\n    },\n  })\n\n  const collectedTags = innerCacheStore.tags\n\n  const isPrivateCacheInDev = Boolean(\n    process.env.__NEXT_DEV_SERVER && cacheContext.kind === 'private'\n  )\n\n  // In development, force a dynamic cache life (`revalidate: 0`, `expire:\n  // MIN_PRERENDERABLE_EXPIRE`) for private caches, which have no real backing\n  // handler. The zero revalidate makes every read serve stale-while-revalidate\n  // (regenerating a fresh entry in the background), and\n  // `MIN_PRERENDERABLE_EXPIRE` (5 minutes) caps how long an entry lingers in\n  // the dedicated in-memory private handler. It is the shortest `expire` that\n  // isn't treated as dynamic; a smaller `expire` would exclude the entry from\n  // prerenders. Two other cases deliberately do NOT force this and keep their\n  // resolved cache life, relying instead on the dev handler's minimum retention\n  // and a dev revalidation (see the cache-hit path below) to keep reloads fast\n  // and fresh. The size-0 case (`cacheMaxMemorySize: 0`) keeps its life so the\n  // entry can be considered prerenderable instead of being misread as a dynamic\n  // hole. An explicit short-`expire` public cache (e.g. `cacheLife({ expire: 0\n  // })`) keeps its life so it stays correctly excluded from static prerenders\n  // via its real `expire` while a reload still hits the cache; forcing\n  // `revalidate: 0` here would instead corrupt the cache life propagated to an\n  // enclosing cache and trigger the nested-dynamic error. A cache backed by a\n  // custom handler keeps its real cache life too, since that handler owns it.\n  const forceDynamicCacheLifeInDev = isPrivateCacheInDev\n\n  // If cacheLife() was used to set an explicit revalidate/expire/stale time we\n  // use that. Otherwise, we use the lowest of all inner fetch(),\n  // unstable_cache() or nested \"use cache\", if they're lower than our default.\n  const collectedRevalidate = forceDynamicCacheLifeInDev\n    ? 0\n    : innerCacheStore.explicitRevalidate !== undefined\n      ? innerCacheStore.explicitRevalidate\n      : innerCacheStore.revalidate\n  const collectedExpire = forceDynamicCacheLifeInDev\n    ? MIN_PRERENDERABLE_EXPIRE\n    : innerCacheStore.explicitExpire !== undefined\n      ? innerCacheStore.explicitExpire\n      : innerCacheStore.expire\n  const collectedStale =\n    innerCacheStore.explicitStale !== undefined\n      ? innerCacheStore.explicitStale\n      : innerCacheStore.stale\n\n  const entry: CacheEntry = {\n    value: bufferStream,\n    timestamp: startTime,\n    revalidate: collectedRevalidate,\n    expire: collectedExpire,\n    stale: collectedStale,\n    tags: collectedTags === null ? [] : collectedTags,\n  }\n\n  const collected: CollectedCacheResult = {\n    entry,\n    hasExplicitRevalidate: innerCacheStore.explicitRevalidate !== undefined,\n    hasExplicitExpire: innerCacheStore.explicitExpire !== undefined,\n    readRootParamNames:\n      innerCacheStore.type === 'cache' || isPrivateCacheInDev\n        ? innerCacheStore.readRootParamNames\n        : undefined,\n    // The store accumulates this from nested public caches that propagated a\n    // dynamic life into us.\n    dynamicNestedCacheError:\n      innerCacheStore.type === 'cache'\n        ? innerCacheStore.dynamicNestedCacheError\n        : undefined,\n  }\n\n  if (!cacheContext.skipPropagation) {\n    maybePropagateCacheEntryMetadata(cacheContext, {\n      tags: collected.entry.tags,\n      revalidate: collected.entry.revalidate,\n      expire: collected.entry.expire,\n      stale: collected.entry.stale,\n      timestamp: collected.entry.timestamp,\n      hasExplicitRevalidate: collected.hasExplicitRevalidate,\n      hasExplicitExpire: collected.hasExplicitExpire,\n      readRootParamNames: collected.readRootParamNames,\n      dynamicNestedCacheError: collected.dynamicNestedCacheError,\n    })\n\n    const cacheSignal = getCacheSignal(cacheContext.outerWorkUnitStore)\n    if (cacheSignal) {\n      cacheSignal.endRead()\n    }\n  }\n\n  return collected\n}\n\ntype GenerateCacheEntryResult =\n  | {\n      readonly type: 'cached'\n      readonly stream: ReadableStream\n      readonly pendingCacheResult: Promise<CollectedCacheResult>\n    }\n  | {\n      readonly type: 'prerender-dynamic'\n      readonly hangingPromise: Promise<never>\n    }\n\nasync function generateCacheEntryImpl(\n  workStore: WorkStore,\n  cacheContext: CacheContext,\n  innerCacheStore: UseCacheStore,\n  clientReferenceManifest: DeepReadonly<ClientReferenceManifest>,\n  encodedArguments: FormData | string,\n  fn: (...args: unknown[]) => Promise<unknown>,\n  timeoutError: UseCacheTimeoutError,\n  deadlockError: UseCacheDeadlockError | undefined\n): Promise<GenerateCacheEntryResult> {\n  const temporaryReferences = createServerTemporaryReferenceSet()\n  const outerWorkUnitStore = cacheContext.outerWorkUnitStore\n\n  const [, , args] =\n    typeof encodedArguments === 'string'\n      ? await decodeReply<CacheKeyParts>(\n          encodedArguments,\n          getServerModuleMap(),\n          { temporaryReferences }\n        )\n      : await decodeReplyFromAsyncIterable<CacheKeyParts>(\n          {\n            async *[Symbol.asyncIterator]() {\n              for (const entry of encodedArguments) {\n                yield entry\n              }\n\n              switch (outerWorkUnitStore.type) {\n                case 'prerender-runtime':\n                case 'prerender':\n                  // The encoded arguments might contain hanging promises. In\n                  // this case we don't want to reject with \"Error: Connection\n                  // closed.\", so we intentionally keep the iterable alive. This\n                  // is similar to the halting trick that we do while rendering.\n                  await new Promise<void>((resolve) => {\n                    if (outerWorkUnitStore.renderSignal.aborted) {\n                      resolve()\n                    } else {\n                      outerWorkUnitStore.renderSignal.addEventListener(\n                        'abort',\n                        () => resolve(),\n                        { once: true }\n                      )\n                    }\n                  })\n                  break\n                case 'prerender-ppr':\n                case 'prerender-legacy':\n                case 'request':\n                case 'cache':\n                case 'private-cache':\n                case 'unstable-cache':\n                case 'generate-static-params':\n                  break\n                default:\n                  outerWorkUnitStore satisfies never\n              }\n            },\n          },\n          getServerModuleMap(),\n          { temporaryReferences }\n        )\n\n  // Track the timestamp when we started computing the result.\n  const startTime = performance.timeOrigin + performance.now()\n\n  // Invoke the inner function to load a new result. We delay the invocation\n  // though, until React awaits the promise so that React's request store (ALS)\n  // is available when the function is invoked. This allows us, for example, to\n  // capture logs so that we can later replay them.\n  const resultPromise = createLazyResult(fn.bind(null, ...args))\n\n  const errors: Array<unknown> = []\n\n  // In the \"Cache\" environment, we only need to make sure that the error\n  // digests are handled correctly. Error formatting and reporting is not\n  // necessary here; the errors are encoded in the stream, and will be reported\n  // in the \"Server\" environment.\n  const handleError = createReactServerErrorHandler(\n    process.env.NODE_ENV === 'development',\n    workStore.isBuildTimePrerendering ?? false,\n    workStore.reactServerErrorsByDigest,\n    (error) => {\n      // In production, we log the original error here. It gets a digest that\n      // can be used to associate the error with the obfuscated error that might\n      // be logged if the error is caught. In development, we prefer logging the\n      // transported error in the server environment. It's not obfuscated and\n      // also includes the (dev-only) environment name.\n      if (process.env.NODE_ENV === 'production') {\n        Log.error(error)\n      }\n\n      errors.push(error)\n    }\n  )\n\n  let stream: ReadableStream<Uint8Array>\n  let devTimeoutAbortController: AbortController | undefined\n\n  switch (outerWorkUnitStore.type) {\n    case 'prerender-runtime':\n    case 'prerender': {\n      const timeoutAbortController = new AbortController()\n      const timer = setTimeout(\n        () => {\n          workStore.invalidDynamicUsageError = timeoutError\n          timeoutAbortController.abort(timeoutError)\n        },\n        getUseCacheFillTimeoutMs(workStore, outerWorkUnitStore.type)\n      )\n\n      const dynamicAccessAbortSignal =\n        dynamicAccessAsyncStorage.getStore()?.abortController.signal\n\n      const abortSignal = dynamicAccessAbortSignal\n        ? AbortSignal.any([\n            dynamicAccessAbortSignal,\n            timeoutAbortController.signal,\n          ])\n        : timeoutAbortController.signal\n\n      const { prelude } = await prerender(\n        resultPromise,\n        clientReferenceManifest.clientModules,\n        {\n          environmentName: 'Cache',\n          filterStackFrame,\n          signal: abortSignal,\n          temporaryReferences,\n          onError(error) {\n            if (abortSignal.aborted && abortSignal.reason === error) {\n              return undefined\n            }\n\n            return handleError(error)\n          },\n        }\n      )\n\n      clearTimeout(timer)\n      const didTimeout = timeoutAbortController.signal.aborted\n      if (dynamicAccessAbortSignal) {\n        // Release React's listener from the composite signal.\n        timeoutAbortController.abort()\n      }\n\n      if (didTimeout) {\n        // When the timeout is reached we always error the stream. Even for\n        // fallback shell prerenders we don't want to return a hanging promise,\n        // which would allow the function to become a dynamic hole. Because that\n        // would mean that a non-empty shell could be generated which would be\n        // subject to revalidation, and we don't want to create long\n        // revalidation times.\n        stream = new ReadableStream({\n          start(controller) {\n            controller.error(timeoutAbortController.signal.reason)\n          },\n        })\n      } else if (dynamicAccessAbortSignal?.aborted) {\n        // If the prerender is aborted because of dynamic access (e.g. reading\n        // fallback params), we return a hanging promise. This essentially makes\n        // the \"use cache\" function dynamic.\n        // The dynamic access is a fallback params read, which is runtime data.\n        const hangingPromise = makeRuntimeHangingPromise<never>(\n          outerWorkUnitStore.renderSignal,\n          workStore.route,\n          'dynamic \"use cache\"',\n          outerWorkUnitStore\n        )\n\n        if (outerWorkUnitStore.cacheSignal) {\n          outerWorkUnitStore.cacheSignal.endRead()\n        }\n\n        return { type: 'prerender-dynamic', hangingPromise }\n      } else {\n        stream = prelude\n      }\n      break\n    }\n    case 'request':\n      // TODO: We should just check if the render is abandonable. This is\n      // relevant in restart-on-cache-miss in general, so when we implement that\n      // for cached navs, it'll also be needed in prod\n      if (process.env.__NEXT_DEV_SERVER && outerWorkUnitStore.cacheSignal) {\n        const stagedRendering = outerWorkUnitStore.stagedRendering\n\n        // Capture the render stage at the start of this cache read, before the\n        // yield below. A streamed staged render advances its controller on its\n        // own schedule, independently of this read, so by the time the yield\n        // resolves the controller may have raced ahead to the Dynamic stage even\n        // though the read began in an earlier (prerender) stage.\n        const stageAtReadStart = stagedRendering?.currentStage\n\n        // If we're filling caches for a staged render, make sure that it takes\n        // at least a task, so we'll always notice a cache miss between stages.\n        //\n        // TODO(restart-on-cache-miss): This is suboptimal. Ideally microtasky\n        // caches wouldn't register as a miss, but short-lived caches are only\n        // omitted correctly when read back in a separate render (now the\n        // background validation render, not a restart of the streamed\n        // response), so forcing the miss is the best we can do until that's\n        // refactored.\n        await new Promise((resolve) => setTimeout(resolve))\n\n        // Start a cache-fill timeout so a hanging `'use cache'` entry surfaces\n        // the same error in dev as during prerender. Cleared when\n        // pendingCacheResult settles.\n        //\n        // Skip the timeout only when the read began in the Dynamic stage, which\n        // mirrors prerender: a cache guarded by e.g. `await connection()` is a\n        // legitimate dynamic hole and isn't executed there. We use the stage\n        // captured at read start, not the current one, because the staged render\n        // may have advanced past it during the yield above.\n        if (stageAtReadStart !== RenderStage.Dynamic) {\n          const devRenderAbortController = new AbortController()\n          const fillTimeoutMs = getUseCacheFillTimeoutMs(\n            workStore,\n            outerWorkUnitStore.type\n          )\n          const fillDeadlineAt = performance.now() + fillTimeoutMs\n          const devRenderTimeoutTimer = setTimeout(() => {\n            workStore.invalidDynamicUsageError = timeoutError\n            devRenderAbortController.abort(timeoutError)\n          }, fillTimeoutMs)\n\n          devTimeoutAbortController = new AbortController()\n          devTimeoutAbortController.signal.addEventListener(\n            'abort',\n            () => {\n              clearTimeout(devRenderTimeoutTimer)\n            },\n            { once: true }\n          )\n\n          stream = renderToReadableStream(\n            resultPromise,\n            clientReferenceManifest.clientModules,\n            {\n              environmentName: 'Cache',\n              filterStackFrame,\n              signal: devRenderAbortController.signal,\n              temporaryReferences,\n              onError(error) {\n                if (\n                  devRenderAbortController.signal.aborted &&\n                  devRenderAbortController.signal.reason === error &&\n                  error instanceof Error\n                ) {\n                  // The abort reason is the same error stored as\n                  // `workStore.invalidDynamicUsageError` (a fill timeout or\n                  // deadlock). Register it under a digest and return that\n                  // digest, so the error that surfaces on the consumer side of\n                  // this Flight boundary carries it and the outer render's\n                  // handler can recover *this* object via\n                  // `reactServerErrorsByDigest`.\n                  //\n                  // We deliberately do not set `error.digest` here: whether the\n                  // error actually surfaces (vs. being caught in userland) is\n                  // the consumer's decision, so the \"surfaced\" mark is left to\n                  // the outer handler.\n                  const digest = createDigestWithErrorCode(\n                    error,\n                    stringHash(error.message + (error.stack || '')).toString()\n                  )\n\n                  workStore.reactServerErrorsByDigest.set(\n                    digest,\n                    error as DigestedError\n                  )\n\n                  return digest\n                }\n\n                return handleError(error)\n              },\n            }\n          )\n\n          // `require` (rather than a top-level import) so the bundler can\n          // tree-shake the probe scheduler out of the production runtime, where\n          // this whole dev-server-gated branch is dead code.\n          const { setupProbeScheduler } =\n            require('./use-cache-probe-scheduler') as typeof import('./use-cache-probe-scheduler')\n          stream = setupProbeScheduler({\n            workStore,\n            outerRequestStore: outerWorkUnitStore,\n            cacheContext,\n            encodedArguments,\n            fillDeadlineAt,\n            stream,\n            abortSignal: AbortSignal.any([\n              devRenderAbortController.signal,\n              devTimeoutAbortController.signal,\n            ]),\n            onProbeCompleted() {\n              const error =\n                deadlockError ??\n                new InvariantError(\n                  '`deadlockError` should be constructed inside `cache()` before reaching the probe scheduler.'\n                )\n              workStore.invalidDynamicUsageError = error\n              devRenderAbortController.abort(error)\n            },\n          })\n          break\n        }\n      }\n    // fallthrough\n    case 'prerender-ppr':\n    case 'prerender-legacy':\n    case 'cache':\n    case 'private-cache':\n    case 'unstable-cache':\n    case 'generate-static-params':\n      stream = renderToReadableStream(\n        resultPromise,\n        clientReferenceManifest.clientModules,\n        {\n          environmentName: 'Cache',\n          filterStackFrame,\n          temporaryReferences,\n          onError: handleError,\n        }\n      )\n      break\n    default:\n      return outerWorkUnitStore satisfies never\n  }\n\n  const [returnStream, savedStream] = stream.tee()\n\n  const pendingCacheResult = collectResult(\n    savedStream,\n    workStore,\n    cacheContext,\n    innerCacheStore,\n    startTime,\n    errors\n  ).finally(() => {\n    devTimeoutAbortController?.abort()\n  })\n\n  if (process.env.NODE_ENV === 'development') {\n    // Name the stream for React DevTools.\n    // @ts-expect-error\n    returnStream.name = 'use cache'\n  }\n\n  return {\n    type: 'cached',\n    // Return the stream as we're creating it. This means that if it ends up\n    // erroring we cannot return a stale-if-error version but it allows\n    // streaming back the result earlier.\n    stream: returnStream,\n    pendingCacheResult,\n  }\n}\n\nfunction cloneCacheResult(\n  result: CollectedCacheResult\n): [CollectedCacheResult, CollectedCacheResult] {\n  const [entryA, entryB] = cloneCacheEntry(result.entry)\n  return [\n    {\n      entry: entryA,\n      hasExplicitRevalidate: result.hasExplicitRevalidate,\n      hasExplicitExpire: result.hasExplicitExpire,\n      readRootParamNames: result.readRootParamNames,\n      dynamicNestedCacheError: result.dynamicNestedCacheError,\n    },\n    {\n      entry: entryB,\n      hasExplicitRevalidate: result.hasExplicitRevalidate,\n      hasExplicitExpire: result.hasExplicitExpire,\n      readRootParamNames: result.readRootParamNames,\n      dynamicNestedCacheError: result.dynamicNestedCacheError,\n    },\n  ]\n}\n\nasync function clonePendingCacheResult(\n  pendingCacheResult: Promise<CollectedCacheResult>\n): Promise<[CollectedCacheResult, CollectedCacheResult]> {\n  const result = await pendingCacheResult\n  return cloneCacheResult(result)\n}\n\nasync function getNthCacheResult(\n  split: Promise<[CollectedCacheResult, CollectedCacheResult]>,\n  i: number\n): Promise<CollectedCacheResult> {\n  return (await split)[i]\n}\n\nasync function encodeFormData(formData: FormData): Promise<string> {\n  let result = ''\n  for (let [key, value] of formData) {\n    // We don't need this key to be serializable but from a security perspective it should not be\n    // possible to generate a string that looks the same from a different structure. To ensure this\n    // we need a delimeter between fields but just using a delimeter is not enough since a string\n    // might contain that delimeter. We use the length of each field as the delimeter to avoid\n    // escaping the values.\n    result += key.length.toString(16) + ':' + key\n    let stringValue\n    if (typeof value === 'string') {\n      stringValue = value\n    } else {\n      // The FormData might contain binary data that is not valid UTF-8 so this cache\n      // key may generate a UCS-2 string. Passing this to another service needs to be\n      // aware that the key might not be compatible.\n      const arrayBuffer = await value.arrayBuffer()\n      if (arrayBuffer.byteLength % 2 === 0) {\n        stringValue = String.fromCodePoint(...new Uint16Array(arrayBuffer))\n      } else {\n        stringValue =\n          String.fromCodePoint(\n            ...new Uint16Array(arrayBuffer, 0, (arrayBuffer.byteLength - 1) / 2)\n          ) +\n          String.fromCodePoint(\n            new Uint8Array(arrayBuffer, arrayBuffer.byteLength - 1, 1)[0]\n          )\n      }\n    }\n    result += stringValue.length.toString(16) + ':' + stringValue\n  }\n  return result\n}\n\nfunction createTrackedReadableStream(\n  stream: ReadableStream,\n  cacheSignal: CacheSignal\n) {\n  const reader = stream.getReader()\n  return new ReadableStream({\n    async pull(controller) {\n      const { done, value } = await reader.read()\n      if (done) {\n        controller.close()\n        cacheSignal.endRead()\n      } else {\n        controller.enqueue(value)\n      }\n    },\n  })\n}\n\nexport async function cache(\n  kind: string,\n  id: string,\n  boundArgsLength: number,\n  originalFn: (...args: unknown[]) => Promise<unknown>,\n  args: unknown[]\n) {\n  const isPrivate = kind === 'private'\n\n  const workStore = workAsyncStorage.getStore()\n  if (workStore === undefined) {\n    throw new Error(\n      '\"use cache\" cannot be used outside of App Router. Expected a WorkStore.'\n    )\n  }\n\n  const workUnitStore = workUnitAsyncStorage.getStore()\n  if (workUnitStore === undefined) {\n    throw new InvariantError(\n      '\"use cache\" cannot be used outside of App Router. Expected a WorkUnitStore.'\n    )\n  }\n\n  // In a prerender, tasky IO may result in cache reads that start\n  // after the prerender has already been aborted:\n  //\n  //   await setTimeout(100)  // we can't abort this uncached IO...\n  //   await cachedData()     // ...so we'll still get here even though the prerender aborted\n  //\n  // The prerender is over, so we should just return an erroring promise.\n  // (NOTE: we also shouldn't fill this cache, because it's behind uncached IO,\n  // so semantically it is not part of the prerender)\n  switch (workUnitStore.type) {\n    case 'prerender':\n    case 'prerender-runtime': {\n      if (workUnitStore.renderSignal.aborted) {\n        // We don't know if the cache itself is dynamic or runtime data,\n        // but the prerender is over, so it doesn't need to participate\n        // in runtime data tracking at all.\n        return makeUntrackedHangingPromise<never>(\n          workUnitStore.renderSignal,\n          workStore.route,\n          '\"use cache\" called after prerender ended'\n        )\n      }\n      break\n    }\n    case 'prerender-ppr':\n    case 'prerender-legacy':\n    case 'prerender-client':\n    case 'validation-client':\n    case 'request':\n    case 'cache':\n    case 'private-cache':\n    case 'unstable-cache':\n    case 'generate-static-params':\n      break\n    default:\n      workUnitStore satisfies never\n  }\n\n  // Probe re-executions (the dev-server's hang-detection worker) short-circuit\n  // further down before any handler is consulted, so we skip handler selection\n  // entirely and the worker can boot without registering handlers at all.\n  let cacheHandler: CacheReadWriteHandler | undefined\n  if (workStore.useCacheProbeMode === undefined) {\n    if (isPrivate) {\n      // Private caches normally go to the Resume Data Cache (RDC), not a cache\n      // handler. In development we additionally persist them in a dedicated\n      // built-in in-memory handler so that reloads are fast.\n      if (process.env.__NEXT_DEV_SERVER) {\n        cacheHandler = getPrivateCacheHandler()\n      }\n    } else {\n      const handler = getCacheHandler(kind)\n      if (!handler) {\n        throw new Error('Unknown cache handler: ' + kind)\n      }\n\n      // In development, a user-configured (custom) handler may be slow or\n      // remote, so we read through a tiered handler that puts a built-in\n      // in-memory front in front of it to keep cache hits microtask-fast.\n      // Built-in handlers (the default handler, and its size-0 replacement) are\n      // already in-memory and used directly.\n      if (process.env.__NEXT_DEV_SERVER && isCustomCacheHandler(kind)) {\n        // A custom kind always has a dev tiered handler: it is created in the\n        // same `setCacheHandler` call that makes `isCustomCacheHandler` true.\n        const tieredCacheHandler = getDevTieredCacheHandler(kind)\n\n        if (!tieredCacheHandler) {\n          throw new InvariantError(\n            `Expected a dev tiered cache handler for kind \"${kind}\".`\n          )\n        }\n\n        cacheHandler = tieredCacheHandler\n      } else {\n        cacheHandler = handler\n      }\n    }\n  }\n\n  const timeoutError = new UseCacheTimeoutError()\n  Error.captureStackTrace(timeoutError, cache)\n  applyOwnerStack(timeoutError)\n\n  // Only ever thrown by the dev-server's hang-detection probe.\n  // `Error.captureStackTrace` has to run while `cache()` is still on the\n  // synchronous stack, otherwise the user's `'use cache'` invocation frames\n  // would already be gone — that's why the construction sits up here rather\n  // than next to the trigger that actually consumes it. The `__NEXT_DEV_SERVER`\n  // gate lets the error class drop out of the production runtime bundle.\n  let deadlockError: UseCacheDeadlockError | undefined\n  if (process.env.__NEXT_DEV_SERVER) {\n    deadlockError = new UseCacheDeadlockError()\n    Error.captureStackTrace(deadlockError, cache)\n    applyOwnerStack(deadlockError)\n  }\n\n  const wrapAsInvalidDynamicUsageError = (error: Error) => {\n    Error.captureStackTrace(error, cache)\n    workStore.invalidDynamicUsageError ??= error\n\n    return error\n  }\n\n  const outerOwnerStack =\n    process.env.NODE_ENV !== 'production'\n      ? captureOuterOwnerStack(workUnitStore)\n      : undefined\n\n  const name = originalFn.name\n  let fn = originalFn\n  let cacheContext: CacheContext\n\n  if (isPrivate) {\n    const expression = '\"use cache: private\"'\n\n    switch (workUnitStore.type) {\n      // \"use cache: private\" is dynamic in prerendering contexts.\n      case 'prerender':\n        // Private caches can read request data, which is runtime data.\n        return makeRuntimeHangingPromise(\n          workUnitStore.renderSignal,\n          workStore.route,\n          expression,\n          workUnitStore\n        )\n      case 'prerender-ppr':\n        return postponeWithTracking(\n          workStore.route,\n          expression,\n          workUnitStore.dynamicTracking\n        )\n      case 'prerender-legacy':\n        return throwToInterruptStaticGeneration(\n          expression,\n          workStore,\n          workUnitStore\n        )\n      case 'prerender-client':\n      case 'validation-client':\n        throw new InvariantError(\n          `${expression} must not be used within a client component. Next.js should be preventing ${expression} from being allowed in client components statically, but did not in this case.`\n        )\n      case 'unstable-cache': {\n        throw wrapAsInvalidDynamicUsageError(\n          new Error(\n            // TODO: Add a link to an error documentation page when we have one.\n            `${expression} must not be used within \\`unstable_cache()\\`.`\n          )\n        )\n      }\n      case 'cache': {\n        throw wrapAsInvalidDynamicUsageError(\n          new Error(\n            // TODO: Add a link to an error documentation page when we have one.\n            `${expression} must not be used within \"use cache\". It can only be nested inside of another ${expression}.`\n          )\n        )\n      }\n      case 'request':\n      case 'prerender-runtime':\n      case 'private-cache':\n        cacheContext = {\n          kind: 'private',\n          outerWorkUnitStore: workUnitStore,\n          skipPropagation: false,\n          outerOwnerStack,\n          functionId: id,\n          handlerKind: kind,\n        }\n        break\n      case 'generate-static-params':\n        throw wrapAsInvalidDynamicUsageError(\n          new Error(\n            // TODO: Add a link to an error documentation page when we have one.\n            `${expression} cannot be used outside of a request context.`\n          )\n        )\n      default:\n        workUnitStore satisfies never\n        // This is dead code, but without throwing an error here, TypeScript\n        // will assume that cacheContext is used before being assigned.\n        throw new InvariantError(`Unexpected work unit store.`)\n    }\n  } else {\n    switch (workUnitStore.type) {\n      case 'prerender-client':\n      case 'validation-client':\n        const expression = '\"use cache\"'\n        throw new InvariantError(\n          `${expression} must not be used within a client component. Next.js should be preventing ${expression} from being allowed in client components statically, but did not in this case.`\n        )\n      case 'cache': {\n        // Eagerly capture this invocation's call site while still synchronous\n        // in `cache()`. Used as `cause` of the nested-dynamic cache error\n        // when the outer cache (whose body never re-runs during the final\n        // prerender) throws. Only constructed when the parent is itself a\n        // public `'use cache'` — otherwise this entry can never propagate\n        // dynamism into that error and the allocation would be wasted. Private\n        // parents are intentionally excluded: `'use cache: private'` is\n        // dynamic-by-definition in prerendering and deferred to the runtime\n        // stage in dev requests, so a public cache nested inside one never\n        // triggers the throw upstream.\n        const dynamicNestedCacheError = new NestedDynamicUseCacheError()\n        Error.captureStackTrace(dynamicNestedCacheError, cache)\n        applyOwnerStack(dynamicNestedCacheError)\n        cacheContext = {\n          kind: 'public',\n          outerWorkUnitStore: workUnitStore,\n          skipPropagation: false,\n          outerOwnerStack,\n          functionId: id,\n          handlerKind: kind,\n          dynamicNestedCacheError,\n        }\n        break\n      }\n      case 'prerender':\n      case 'prerender-runtime':\n      case 'prerender-ppr':\n      case 'prerender-legacy':\n      case 'request':\n      case 'private-cache':\n      // TODO: We should probably forbid nesting \"use cache\" inside\n      // unstable_cache. (fallthrough)\n      case 'unstable-cache':\n      case 'generate-static-params':\n        cacheContext = {\n          kind: 'public',\n          outerWorkUnitStore: workUnitStore,\n          skipPropagation: false,\n          outerOwnerStack,\n          functionId: id,\n          handlerKind: kind,\n          dynamicNestedCacheError: undefined,\n        }\n        break\n      default:\n        workUnitStore satisfies never\n        // This is dead code, but without throwing an error here, TypeScript\n        // will assume that cacheContext is used before being assigned.\n        throw new InvariantError(`Unexpected work unit store.`)\n    }\n  }\n\n  // Get the clientReferenceManifest while we're still in the outer Context.\n  // In case getClientReferenceManifestSingleton is implemented using AsyncLocalStorage.\n  const clientReferenceManifest = getClientReferenceManifest()\n\n  // Because the Action ID is not yet unique per implementation of that Action we can't\n  // safely reuse the results across builds yet. In the meantime we add the buildId to the\n  // arguments as a seed to ensure they're not reused. Remove this once Action IDs hash\n  // the implementation.\n  const buildId = workStore.deploymentId || workStore.buildId\n\n  // In dev mode, when the HMR refresh hash is set, we include it in the\n  // cache key. This ensures that cache entries are not reused when server\n  // components have been edited. This is a very coarse approach. But it's\n  // also only a temporary solution until Action IDs are unique per\n  // implementation. Remove this once Action IDs hash the implementation.\n  const hmrRefreshHash = getHmrRefreshHash(workUnitStore)\n\n  const hangingInputAbortSignal = createHangingInputAbortSignal(workUnitStore)\n\n  if (cacheContext.kind === 'private') {\n    const { outerWorkUnitStore } = cacheContext\n    switch (outerWorkUnitStore.type) {\n      case 'prerender-runtime': {\n        // In a runtime prerender, we have to make sure that APIs that would hang during a static prerender\n        // are resolved with a delay, in the appropriate runtime stage. Private caches resolve in EarlyRuntime,\n        const stagedRendering = outerWorkUnitStore.stagedRendering\n        if (stagedRendering) {\n          await stagedRendering.waitForStage(\n            RENDER_STAGES_BY_DATA_KIND.sessionData\n          )\n        }\n        break\n      }\n      case 'request': {\n        if (process.env.NODE_ENV === 'development') {\n          // Similar to runtime prerenders, private caches should not resolve in the static stage\n          // of a dev request, so we delay them.\n          await makeDevtoolsIOAwarePromise(\n            undefined,\n            outerWorkUnitStore,\n            RENDER_STAGES_BY_DATA_KIND.sessionData\n          )\n        }\n        break\n      }\n      case 'private-cache':\n        break\n      default: {\n        outerWorkUnitStore satisfies never\n      }\n    }\n  }\n\n  let isPageOrLayoutSegmentFunction = false\n\n  // For page and layout segment functions (i.e. the page/layout component,\n  // or generateMetadata/generateViewport), the cache function is\n  // overwritten, which allows us to apply special handling for params and\n  // searchParams. For pages and layouts we're using the outer params prop,\n  // and not the inner one that was serialized/deserialized. While it's not\n  // generally true for \"use cache\" args, in the case of `params` the inner\n  // and outer object are essentially equivalent, so this is safe to do\n  // (including fallback params that are hanging promises). It allows us to\n  // avoid waiting for the timeout, when prerendering a fallback shell of a\n  // cached page or layout that awaits params.\n  if (isPageSegmentFunction(args)) {\n    isPageOrLayoutSegmentFunction = true\n\n    const [\n      { params: outerParams, searchParams: outerSearchParams },\n      ...otherOuterArgs\n    ] = args\n\n    const props: UseCachePageInnerProps = {\n      params: outerParams,\n      // Omit searchParams and $$isPage.\n    }\n\n    if (isPrivate) {\n      // Private caches allow accessing search params. We need to include\n      // them in the serialized args and when generating the cache key.\n      props.searchParams = outerSearchParams\n    }\n\n    args = [props, ...otherOuterArgs]\n\n    fn = {\n      [name]: async (\n        {\n          params: _innerParams,\n          searchParams: innerSearchParams,\n        }: UseCachePageInnerProps,\n        ...otherInnerArgs: unknown[]\n      ) =>\n        originalFn.apply(null, [\n          {\n            params: outerParams,\n            searchParams:\n              innerSearchParams ??\n              // For public caches, search params are omitted from the cache\n              // key (and the serialized args) to avoid mismatches between\n              // prerendering and resuming a cached page that does not\n              // access search params. This is also the reason why we're not\n              // using a hanging promise for search params. For cached pages\n              // that do access them, which is an invalid dynamic usage, we\n              // need to ensure that an error is shown.\n              makeErroringSearchParamsForUseCache(),\n          },\n          ...otherInnerArgs,\n        ]),\n    }[name] as (...args: unknown[]) => Promise<unknown>\n  } else if (isLayoutSegmentFunction(args)) {\n    isPageOrLayoutSegmentFunction = true\n\n    const [\n      { params: outerParams, $$isLayout, ...outerSlots },\n      ...otherOuterArgs\n    ] = args\n\n    // Overwrite the props to omit $$isLayout. Note that slots are only\n    // passed to the layout component (if any are defined), and not to\n    // generateMetadata nor generateViewport. For those functions,\n    // outerSlots/innerSlots is an empty object, which is fine because we're\n    // just spreading it into the props.\n    args = [{ params: outerParams, ...outerSlots }, ...otherOuterArgs]\n\n    fn = {\n      [name]: async (\n        {\n          params: _innerParams,\n          ...innerSlots\n        }: Omit<UseCacheLayoutProps, '$$isLayout'>,\n        ...otherInnerArgs: unknown[]\n      ) =>\n        originalFn.apply(null, [\n          { params: outerParams, ...innerSlots },\n          ...otherInnerArgs,\n        ]),\n    }[name] as (...args: unknown[]) => Promise<unknown>\n  }\n\n  if (boundArgsLength > 0) {\n    if (args.length === 0) {\n      throw new InvariantError(\n        `Expected the \"use cache\" function ${JSON.stringify(fn.name)} to receive its encrypted bound arguments as the first argument.`\n      )\n    }\n\n    const encryptedBoundArgs = args.shift() as Promise<string>\n    const boundArgs = await decryptActionBoundArgs(id, encryptedBoundArgs)\n\n    if (!Array.isArray(boundArgs)) {\n      throw new InvariantError(\n        `Expected the bound arguments of \"use cache\" function ${JSON.stringify(fn.name)} to deserialize into an array, got ${typeof boundArgs} instead.`\n      )\n    }\n\n    if (boundArgsLength !== boundArgs.length) {\n      throw new InvariantError(\n        `Expected the \"use cache\" function ${JSON.stringify(fn.name)} to receive ${boundArgsLength} bound arguments, got ${boundArgs.length} instead.`\n      )\n    }\n\n    args.unshift(boundArgs)\n  }\n\n  const temporaryReferences = createClientTemporaryReferenceSet()\n\n  // The base serialized cache key doesn't include the cookies or headers that\n  // private caches are allowed to read. In production this is because private\n  // cache entries aren't stored in a cache handler, only in the Resume Data\n  // Cache (RDC): private caches are only used during dynamic requests and\n  // runtime prefetches; for dynamic requests the RDC is immutable and excludes\n  // private caches, and for runtime prefetches it's mutable but lives only as\n  // long as the request. In development private caches are persisted across\n  // requests, so `cacheHandlerKeyBase` (below) additionally scopes the handler\n  // key by the request's cookies and headers.\n  const cacheKeyParts: CacheKeyParts = hmrRefreshHash\n    ? [buildId, id, args, hmrRefreshHash]\n    : [buildId, id, args]\n\n  const encodeCacheKeyParts = () =>\n    encodeReply(cacheKeyParts, {\n      temporaryReferences,\n      signal: hangingInputAbortSignal,\n    })\n\n  let encodedCacheKeyParts: FormData | string\n\n  switch (workUnitStore.type) {\n    case 'prerender-runtime':\n    // We're currently only using `dynamicAccessAsyncStorage` for params,\n    // which are always available in a runtime prerender, so they will never hang,\n    // effectively making the tracking below a no-op.\n    // However, a runtime prerender shares a lot of the semantics with a static prerender,\n    // and might need to follow this codepath in the future\n    // if we start using `dynamicAccessAsyncStorage` for other APIs.\n    //\n    // fallthrough\n    case 'prerender':\n      if (!isPageOrLayoutSegmentFunction) {\n        // If the \"use cache\" function is not a page or layout segment\n        // function, we need to track dynamic access already when encoding\n        // the arguments. If params are passed explicitly into a \"use cache\"\n        // function (as opposed to receiving them automatically in a page or\n        // layout), we assume that the params are also accessed. This allows\n        // us to abort early, and treat the function as dynamic, instead of\n        // waiting for the timeout to be reached.\n        const dynamicAccessAbortController = new AbortController()\n\n        encodedCacheKeyParts = await dynamicAccessAsyncStorage.run(\n          { abortController: dynamicAccessAbortController },\n          encodeCacheKeyParts\n        )\n\n        if (dynamicAccessAbortController.signal.aborted) {\n          // The dynamic access is a fallback params read, which is runtime\n          // data.\n          return makeRuntimeHangingPromise(\n            workUnitStore.renderSignal,\n            workStore.route,\n            'dynamic \"use cache\"',\n            workUnitStore\n          )\n        }\n        break\n      }\n    // fallthrough\n    case 'prerender-ppr':\n    case 'prerender-legacy':\n    case 'request':\n    // TODO(restart-on-cache-miss): We need to handle params/searchParams on page components.\n    // the promises will be tasky, so `encodeCacheKeyParts` will not resolve in the static stage.\n    // We have not started a cache read at this point, so we might just miss the cache completely.\n    // fallthrough\n    case 'cache':\n    case 'private-cache':\n    case 'unstable-cache':\n    case 'generate-static-params':\n    case undefined:\n      encodedCacheKeyParts = await encodeCacheKeyParts()\n      break\n    default:\n      return workUnitStore satisfies never\n  }\n\n  // Probe path: we're running inside a pooled worker spawned by the dev\n  // server to check whether a stalled cache fill would complete in an\n  // isolated module scope. Skip the RDC / cache-handler / leader-election\n  // machinery, call `generateCacheEntry` (same as a real cold fill), drain\n  // the returned stream via `pendingCacheResult`, and apply the probe's own\n  // timeout. The caller only cares whether the fill resolves; the result\n  // value is discarded.\n  //\n  // Gated on `__NEXT_DEV_SERVER` so the entire branch — including its\n  // `generateCacheEntry` call site and the threading of\n  // `deadlockError` — drops out of the production runtime\n  // bundle.\n  if (process.env.__NEXT_DEV_SERVER && workStore.useCacheProbeMode) {\n    // Both public and private caches probe via the same path. The worker\n    // reconstructs real `headers` / `cookies` / `draftMode` from the\n    // forwarded request snapshot, so private caches that legitimately read\n    // those work in the probe just like in the real fill.\n    const probeTimeoutMs = workStore.useCacheProbeMode.timeoutMs\n    // The deadlock error never gets thrown from inside the worker: the\n    // worker's outer store has `cacheSignal: undefined`, so\n    // `generateCacheEntryImpl` skips the dev-request branch and the idle\n    // probe is never set up.\n    const result = await generateCacheEntry(\n      workStore,\n      cacheContext,\n      clientReferenceManifest,\n      encodedCacheKeyParts,\n      fn,\n      timeoutError,\n      undefined\n    )\n    if (result.type === 'prerender-dynamic') {\n      // Unreachable in the probe: outer store is `'request'`-typed, which\n      // never produces this variant.\n      throw new InvariantError(\n        'Unexpected `prerender-dynamic` result in `use cache` probe mode.'\n      )\n    }\n    // We don't consume the returned stream — `pendingCacheResult` is what\n    // completes when `collectResult` has drained `savedStream`. Cancel the\n    // unused copy so it doesn't buffer forever.\n    result.stream.cancel().catch(() => {})\n    let probeTimeoutTimer: ReturnType<typeof setTimeout> | undefined\n    try {\n      await Promise.race([\n        result.pendingCacheResult,\n        new Promise<never>((_, reject) => {\n          probeTimeoutTimer = setTimeout(\n            () => reject(timeoutError),\n            probeTimeoutMs\n          )\n        }),\n      ])\n    } finally {\n      if (probeTimeoutTimer !== undefined) {\n        clearTimeout(probeTimeoutTimer)\n      }\n    }\n    return\n  }\n\n  const serializedCacheKey =\n    typeof encodedCacheKeyParts === 'string'\n      ? // Fast path for the simple case for simple inputs. We let the CacheHandler\n        // Convert it to an ArrayBuffer if it wants to.\n        encodedCacheKeyParts\n      : await encodeFormData(encodedCacheKeyParts)\n\n  const rootParams = workUnitStore.rootParams\n  const knownRootParamNames = knownRootParamsByFunctionId.get(id)\n\n  // The coarse cache-handler key. With no root params read, it locates the\n  // entry directly; otherwise it locates a redirect entry from which the\n  // specific key (this key + root params, computed below) is derived. For\n  // private caches in development (persisted in the built-in in-memory handler)\n  // it's additionally scoped by the request's cookies and headers, so entries\n  // for requests with different request data don't collide; keys derived from\n  // it inherit that scoping.\n  const cacheHandlerKeyBase =\n    process.env.__NEXT_DEV_SERVER && cacheContext.kind === 'private'\n      ? serializedCacheKey +\n        computePrivateCacheKeyRequestSuffix(\n          cacheContext.outerWorkUnitStore.cookies,\n          cacheContext.outerWorkUnitStore.headers\n        )\n      : serializedCacheKey\n  // If we already know which root params this function reads, include them in\n  // the cache handler key for a direct hit (skipping the redirect entry).\n  // rootParams is undefined when nested inside unstable_cache.\n  let cacheHandlerKey =\n    knownRootParamNames && rootParams\n      ? cacheHandlerKeyBase +\n        computeRootParamsCacheKeySuffix(rootParams, knownRootParamNames)\n      : cacheHandlerKeyBase\n\n  let stream: undefined | ReadableStream = undefined\n\n  // Set when a short-lived cache hit ends its cache read up front (dev only) so\n  // the static-shell boundary doesn't count it as a phantom miss. Once set, the\n  // cache signal read is balanced, so serving must use a plain stream and skip\n  // any trailing cacheSignal.endRead() call.\n  let cacheSignalReadEnded = false\n\n  const resumeDataCache = getResumeDataCache(workUnitStore)\n\n  const implicitTags = workUnitStore.implicitTags?.tags ?? []\n\n  if (resumeDataCache) {\n    // If this cache key was already determined to be dynamic during the\n    // prospective prerender (e.g. because it accessed fallback params), we\n    // return a hanging promise early to avoid trying to regenerate the entry,\n    // which would be aborted anyway.\n    if (resumeDataCache.dynamicCacheKeys?.has(serializedCacheKey)) {\n      switch (workUnitStore.type) {\n        case 'prerender':\n        case 'prerender-runtime':\n          // The cache key was marked dynamic because it depends on fallback\n          // params, which are runtime data.\n          return makeRuntimeHangingPromise(\n            workUnitStore.renderSignal,\n            workStore.route,\n            'dynamic \"use cache\"',\n            workUnitStore\n          )\n        case 'prerender-ppr':\n        case 'prerender-legacy':\n        case 'request':\n        case 'cache':\n        case 'private-cache':\n        case 'unstable-cache':\n        case 'generate-static-params':\n          break\n        default:\n          workUnitStore satisfies never\n      }\n    }\n\n    const cacheSignal = getCacheSignal(workUnitStore)\n\n    if (cacheSignal) {\n      cacheSignal.beginRead()\n    }\n    const rdcEntry = resumeDataCache.cache.get(serializedCacheKey)\n    if (rdcEntry !== undefined) {\n      let rdcResult: CollectedCacheResult | undefined = await rdcEntry\n\n      // Check if the RDC entry should be discarded due to recently revalidated\n      // tags. When a server action calls updateTag(), the re-render should see\n      // fresh data instead of stale RDC data.\n      if (rdcResult !== undefined) {\n        const { timestamp } = rdcResult.entry\n\n        if (\n          rdcResult.entry.tags.some((tag) =>\n            isRevalidatedAfter(tag, timestamp, workStore)\n          ) ||\n          implicitTags.some((tag) =>\n            isRevalidatedAfter(tag, timestamp, workStore)\n          )\n        ) {\n          debug?.(\n            'discarding RDC entry due to recently revalidated tags',\n            serializedCacheKey\n          )\n          rdcResult = undefined\n        }\n      }\n\n      if (rdcResult !== undefined) {\n        if (\n          rdcResult.entry.revalidate === 0 ||\n          rdcResult.entry.expire < MIN_PRERENDERABLE_EXPIRE\n        ) {\n          // The nested-cache error only makes sense when a dynamic nested cache\n          // actually shortened an outer cache that has no explicit `cacheLife`\n          // (`dynamicNestedCacheError` is set), and only when the app's default\n          // profile is itself prerenderable. If the default profile is already\n          // dynamic (`revalidate: 0` or an `expire` under the prerenderable\n          // minimum), every cache is omitted from prerenders by default, so\n          // there is no silent degradation to warn about. A short life from the\n          // default profile, or from a dev private cache's self-imposed\n          // `revalidate: 0` (which never carries a nested error), therefore\n          // stays a dynamic hole rather than erroring.\n          const defaultCacheLife = workStore.cacheLifeProfiles.default\n          const shouldReportNestedCacheError =\n            rdcResult.dynamicNestedCacheError !== undefined &&\n            defaultCacheLife.revalidate !== 0 &&\n            defaultCacheLife.expire >= MIN_PRERENDERABLE_EXPIRE\n\n          switch (workUnitStore.type) {\n            case 'prerender':\n              // In a Dynamic I/O prerender, if the cache entry has\n              // revalidate: 0 or if the expire time is under 5 minutes,\n              // then we consider this cache entry dynamic as it's not worth\n              // generating static pages for such data. It's better to leave\n              // a dynamic hole that can be filled in during the resume with\n              // a potentially cached entry.\n              if (rdcResult.entry.revalidate === 0) {\n                if (\n                  rdcResult.hasExplicitRevalidate === false &&\n                  shouldReportNestedCacheError\n                ) {\n                  throw wrapAsInvalidDynamicUsageError(\n                    new Error(nestedCacheZeroRevalidateErrorMessage, {\n                      cause: rdcResult.dynamicNestedCacheError,\n                    })\n                  )\n                }\n                debug?.(\n                  'omitting entry',\n                  serializedCacheKey,\n                  'from static shell due to revalidate: 0'\n                )\n              } else {\n                if (\n                  rdcResult.hasExplicitExpire === false &&\n                  shouldReportNestedCacheError\n                ) {\n                  throw wrapAsInvalidDynamicUsageError(\n                    new Error(nestedCacheShortExpireErrorMessage, {\n                      cause: rdcResult.dynamicNestedCacheError,\n                    })\n                  )\n                }\n                debug?.(\n                  'omitting entry',\n                  serializedCacheKey,\n                  'from static shell due to short expire value:',\n                  rdcResult.entry.expire\n                )\n              }\n              if (cacheSignal) {\n                cacheSignal.endRead()\n              }\n              // The entry is only excluded from *static* prerenders — the\n              // 'prerender-runtime' case below serves it — so a runtime\n              // prefetch would include this content.\n              return makeRuntimeHangingPromise(\n                workUnitStore.renderSignal,\n                workStore.route,\n                'dynamic \"use cache\"',\n                workUnitStore\n              )\n            case 'prerender-runtime': {\n              // In the final phase of a runtime prerender, we have to make\n              // sure that APIs that would hang during a static prerender\n              // are resolved with a delay, in the appropriate runtime stage.\n              const stagedRendering = workUnitStore.stagedRendering\n              if (stagedRendering) {\n                await stagedRendering.waitForStage(\n                  RENDER_STAGES_BY_DATA_KIND.sessionData\n                )\n              }\n              break\n            }\n            case 'request': {\n              if (process.env.NODE_ENV === 'development') {\n                // These throws force an explicit cache life decision on an\n                // outer cache that a nested cache would otherwise silently\n                // shorten (see `shouldReportNestedCacheError` above). Otherwise\n                // the short-lived entry is deferred as a dynamic hole below.\n                if (\n                  rdcResult.entry.revalidate === 0 &&\n                  rdcResult.hasExplicitRevalidate === false &&\n                  shouldReportNestedCacheError\n                ) {\n                  throw wrapAsInvalidDynamicUsageError(\n                    new Error(nestedCacheZeroRevalidateErrorMessage, {\n                      cause: rdcResult.dynamicNestedCacheError,\n                    })\n                  )\n                }\n                if (\n                  rdcResult.entry.expire < MIN_PRERENDERABLE_EXPIRE &&\n                  rdcResult.hasExplicitExpire === false &&\n                  shouldReportNestedCacheError\n                ) {\n                  throw wrapAsInvalidDynamicUsageError(\n                    new Error(nestedCacheShortExpireErrorMessage, {\n                      cause: rdcResult.dynamicNestedCacheError,\n                    })\n                  )\n                }\n                // A short-lived entry is a dynamic hole, excluded from the\n                // static shell, so we end the cache signal read here (the\n                // prerender case does the same) to avoid this cache hit being\n                // considered a cache miss when checking for pending cache reads\n                // at staged rendering task boundaries. The value is deferred to\n                // the runtime stage.\n                if (cacheSignal && !cacheSignalReadEnded) {\n                  cacheSignal.endRead()\n                  cacheSignalReadEnded = true\n                }\n\n                await makeDevtoolsIOAwarePromise(\n                  undefined,\n                  workUnitStore,\n                  RENDER_STAGES_BY_DATA_KIND.sessionData\n                )\n              }\n              break\n            }\n            case 'prerender-ppr':\n            case 'prerender-legacy':\n            case 'cache':\n            case 'private-cache':\n            case 'unstable-cache':\n            case 'generate-static-params':\n              break\n            default:\n              workUnitStore satisfies never\n          }\n        }\n\n        if (rdcResult.entry.stale < MIN_SHELL_STALE) {\n          // The entry's stale time is short enough that it's excluded from\n          // shells. If it's below `MIN_PREFETCHABLE_STALE`, it's not worth\n          // prefetching at all and is excluded from prerenders entirely,\n          // leaving a dynamic hole that can be filled during the navigation.\n          // Otherwise, it's still included in prerenders and cached\n          // navigations, but it must not be part of an App Shell, which may\n          // be reused on the client for longer than the entry's stale time.\n          // We delay the entry to resolve in the post-shell (link data)\n          // stage, which excludes both its content and its stale time from\n          // the shell.\n          const isPrefetchable = rdcResult.entry.stale >= MIN_PREFETCHABLE_STALE\n          switch (workUnitStore.type) {\n            case 'prerender':\n            case 'prerender-runtime': {\n              const prerenderStore = workUnitStore\n              // The post-shell stage that the entry must be delayed to.\n              let postShellStage: AdvanceableRenderStage\n              if (prerenderStore.type === 'prerender') {\n                postShellStage = RENDER_STAGES_BY_DATA_KIND.staticLinkData\n              } else {\n                postShellStage = RENDER_STAGES_BY_DATA_KIND.runtimeLinkData\n              }\n              const stagedRendering = prerenderStore.stagedRendering\n              if (\n                !isPrefetchable ||\n                // If the render ends before the post-shell stage (e.g. a\n                // render that only produces an App Shell), the entry can't\n                // be delayed and is omitted entirely.\n                (stagedRendering !== null &&\n                  stagedRendering.finalStage !== null &&\n                  stagedRendering.finalStage < postShellStage)\n              ) {\n                debug?.(\n                  'omitting entry',\n                  serializedCacheKey,\n                  'from shell due to short stale value:',\n                  rdcResult.entry.stale\n                )\n                if (cacheSignal) {\n                  cacheSignal.endRead()\n                }\n                if (isPrefetchable) {\n                  // The entry was omitted only because this render ends\n                  // before the post-shell stage; a render that reaches its\n                  // post-shell stage would serve it.\n                  return makeStageHangingPromise(\n                    prerenderStore.renderSignal,\n                    workStore.route,\n                    'dynamic \"use cache\"',\n                    prerenderStore\n                  )\n                }\n                // An unprefetchable entry (stale < MIN_PREFETCHABLE_STALE) is\n                // excluded from runtime prerenders too.\n                return makeDynamicHangingPromise(\n                  prerenderStore.renderSignal,\n                  workStore.route,\n                  'dynamic \"use cache\"'\n                )\n              }\n              if (stagedRendering !== null) {\n                debug?.(\n                  'delaying entry',\n                  serializedCacheKey,\n                  'until after the shell stage due to short stale value:',\n                  rdcResult.entry.stale\n                )\n                await stagedRendering.waitForStage(postShellStage)\n              }\n              break\n            }\n            case 'request': {\n              // A request store in `next start` never delays caches — shells\n              // are produced by separate (runtime) prerenders, which apply\n              // the exclusions above. In dev, the request render is also used\n              // to recover shells, so we delay the entry here to match.\n              if (process.env.NODE_ENV === 'development') {\n                // End the cache signal read (once, in case an earlier block\n                // already did) so the delayed value isn't counted as a pending\n                // read at a staged rendering boundary.\n                if (cacheSignal && !cacheSignalReadEnded) {\n                  cacheSignal.endRead()\n                  cacheSignalReadEnded = true\n                }\n                // An unprefetchable entry is excluded from prerenders, so it\n                // resolves in the dynamic stage. Otherwise, a dynamic request\n                // generally recovers a static shell, so the entry can resolve\n                // in the static link data stage. If we need to recover a\n                // session shell instead, as indicated by `needsSessionShell`,\n                // the entry must resolve after the session data stage that\n                // the shell includes.\n                let stage: AdvanceableRenderStage\n                if (!isPrefetchable) {\n                  stage = RenderStage.Dynamic\n                } else if (workUnitStore.needsSessionShell) {\n                  stage = RENDER_STAGES_BY_DATA_KIND.runtimeLinkData\n                } else {\n                  stage = RENDER_STAGES_BY_DATA_KIND.staticLinkData\n                }\n                await makeDevtoolsIOAwarePromise(\n                  undefined,\n                  workUnitStore,\n                  stage\n                )\n              }\n              break\n            }\n            case 'prerender-ppr':\n            case 'prerender-legacy':\n            case 'cache':\n            case 'private-cache':\n            case 'unstable-cache':\n            case 'generate-static-params':\n              break\n            default:\n              workUnitStore satisfies never\n          }\n        }\n      }\n\n      if (rdcResult !== undefined) {\n        debug?.('Resume Data Cache entry found', serializedCacheKey)\n\n        if (\n          rdcResult.readRootParamNames &&\n          rdcResult.readRootParamNames.size > 0\n        ) {\n          addKnownRootParamNames(id, rdcResult.readRootParamNames)\n        }\n\n        // We want to make sure we only propagate cache life & tags if the\n        // entry was *not* omitted from the prerender. So we only do this\n        // after the above early returns.\n        propagateCacheEntryMetadata(cacheContext, {\n          tags: rdcResult.entry.tags,\n          revalidate: rdcResult.entry.revalidate,\n          expire: rdcResult.entry.expire,\n          stale: rdcResult.entry.stale,\n          timestamp: rdcResult.entry.timestamp,\n          hasExplicitRevalidate: rdcResult.hasExplicitRevalidate,\n          hasExplicitExpire: rdcResult.hasExplicitExpire,\n          readRootParamNames: rdcResult.readRootParamNames,\n          dynamicNestedCacheError: rdcResult.dynamicNestedCacheError,\n        })\n\n        const [streamA, streamB] = rdcResult.entry.value.tee()\n        rdcResult.entry.value = streamB\n\n        if (cacheSignal && !cacheSignalReadEnded) {\n          // When we have a cacheSignal we need to block on reading the cache\n          // entry before ending the read.\n          stream = createTrackedReadableStream(streamA, cacheSignal)\n        } else {\n          // The cache signal read was already ended for a short-lived deferral\n          // (or there is no cacheSignal), so serve a plain stream.\n          stream = streamA\n        }\n      } else {\n        // Entry was discarded (e.g. due to recently revalidated tags)\n        debug?.('Resume Data Cache entry discarded', serializedCacheKey)\n\n        if (cacheSignal) {\n          cacheSignal.endRead()\n        }\n      }\n    } else {\n      debug?.('Resume Data Cache entry not found', serializedCacheKey)\n\n      if (cacheSignal) {\n        cacheSignal.endRead()\n      }\n\n      switch (workUnitStore.type) {\n        case 'prerender':\n          if (resumeDataCache?.mutable === false) {\n            // We're prerendering a fallback shell whose Resume Data Cache is\n            // the prefilled, read-only seed from a phase-1 prerender of a more-\n            // specific sibling route. A miss here means the cache key depends\n            // on a fallback param. We short-circuit to a dynamic hole (which\n            // may produce an empty shell if there's no parent Suspense\n            // boundary). Currently this also catches layouts and pages that\n            // don't read params, which will be improved when we implement\n            // NAR-136. Compared to the instrumentation-based params bailout we\n            // also do here, this covers the case where params are transformed\n            // with an async function before being passed into the \"use cache\"\n            // function, which escapes the instrumentation.\n            // The cache key depends on fallback params, which are runtime\n            // data.\n            return makeRuntimeHangingPromise(\n              workUnitStore.renderSignal,\n              workStore.route,\n              'dynamic \"use cache\"',\n              workUnitStore\n            )\n          }\n        // fallthrough\n        case 'prerender-runtime':\n          if (!cacheSignal) {\n            // This is the final prerender (cacheSignal is null), which means\n            // all caches should have been warmed during the prospective\n            // prerender. A cache miss here indicates that the cache key is\n            // non-deterministic (e.g. due to unstable array order in the\n            // arguments). Known dynamic keys (e.g. from fallback params) are\n            // already handled by the early return above. We return a hanging\n            // promise so this becomes a dynamic hole rather than generating a\n            // broken cache entry that gets aborted.\n            console.warn(\n              new Error(\n                `Unexpected cache miss after cache warming phase during prerendering. This is likely caused by non-deterministic arguments that differ between the cache warming phase and the final prerender phase (e.g. unstable array order). Ensure that arguments passed to cached functions are deterministic.`\n              )\n            )\n            // This is an anomaly (non-deterministic cache key), so we can't\n            // know whether a runtime prerender would resolve it. Treat it as\n            // runtime data, conservatively: the cost is at most a redundant\n            // runtime prefetch request.\n            return makeRuntimeHangingPromise(\n              workUnitStore.renderSignal,\n              workStore.route,\n              'dynamic \"use cache\"',\n              workUnitStore\n            )\n          }\n          break\n        case 'prerender-ppr':\n        case 'prerender-legacy':\n        case 'request':\n        case 'cache':\n        case 'private-cache':\n        case 'unstable-cache':\n        case 'generate-static-params':\n          break\n        default:\n          workUnitStore satisfies never\n      }\n    }\n  }\n\n  // Intra-request deduplication: Within a single request, root params are\n  // fixed, so the coarse key (serializedCacheKey) is sufficient. If another\n  // invocation in this request is already handling the same cache entry\n  // (including the cache handler lookup and generation), we join it instead of\n  // doing redundant work. This also saves cache handler `get` calls which may\n  // be HTTP round-trips for remote handlers.\n  if (stream === undefined) {\n    const pendingInvocation =\n      workStore.pendingCacheInvocations?.get(serializedCacheKey)\n\n    // A pending invocation is joined unconditionally: its fill is shared, so\n    // every joiner receives whatever that fill produces. A completed one is a\n    // stored entry instead, so it is only reused when the caller hasn't asked\n    // to bypass caches, and only if nothing has invalidated it since.\n    const completedInvocation =\n      pendingInvocation === undefined &&\n      !shouldForceRevalidate(workStore, workUnitStore)\n        ? workStore.completedCacheInvocations?.get(serializedCacheKey)\n        : undefined\n\n    const joinedInvocation = pendingInvocation ?? completedInvocation\n\n    if (joinedInvocation) {\n      const cacheSignal = getCacheSignal(workUnitStore)\n      cacheSignal?.beginRead()\n\n      debug?.('joining intra-request invocation', serializedCacheKey)\n      const sharedCacheResult = await joinedInvocation\n\n      if (sharedCacheResult.type === 'prerender-dynamic') {\n        debug?.('joined invocation is prerender-dynamic', serializedCacheKey)\n        cacheSignal?.endRead()\n        return sharedCacheResult.hangingPromise\n      }\n\n      // A completed entry may have been invalidated since it was produced, by\n      // an `updateTag()` in a server action earlier in this request. The\n      // implicit tags expiration is passed as 0 because it cannot apply to a\n      // retained entry: it is memoized for the request, so re-checking it\n      // against an unchanged entry timestamp only repeats the answer the leader\n      // already got.\n      const metadata =\n        completedInvocation === undefined\n          ? undefined\n          : await sharedCacheResult.entry.pendingMetadata\n\n      if (\n        metadata !== undefined &&\n        shouldDiscardCacheEntry(\n          metadata,\n          workStore,\n          workUnitStore,\n          implicitTags,\n          0\n        )\n      ) {\n        debug?.('discarding completed invocation', serializedCacheKey)\n        workStore.completedCacheInvocations?.delete(serializedCacheKey)\n\n        // This can take the signal's count to zero. The leader path below opens\n        // a read again synchronously, before it awaits anything, which is what\n        // stops a prerender from concluding that every cache read has settled\n        // while a fill is still about to start.\n        cacheSignal?.endRead()\n      } else {\n        debug?.(\n          'joined invocation resolved with cached entry',\n          serializedCacheKey\n        )\n\n        stream = serveJoinedCacheEntry(\n          sharedCacheResult.entry,\n          serializedCacheKey,\n          resumeDataCache,\n          cacheContext,\n          cacheSignal\n        )\n      }\n    }\n  }\n\n  // Leader path: no pending intra-request invocation found. Check for a\n  // cross-request pending invocation, or become the leader for both.\n  if (stream === undefined) {\n    const resolvableSharedCacheResult = new ResolvableSharedCacheResult()\n\n    debug?.(\n      'registering as intra-request invocation leader',\n      serializedCacheKey\n    )\n    const intraRequestPendingCacheInvocations =\n      (workStore.pendingCacheInvocations ??= new Map<\n        string,\n        Promise<SharedCacheResult>\n      >())\n\n    // Retain the completed entry for the rest of the request where a later\n    // invocation would otherwise repeat real work: private caches have no cache\n    // handler to fall back on in production, and a platform- or config-supplied\n    // handler may be remote, so a second `get` can be a round trip. A built-in\n    // handler read is a map lookup, so retaining its entries would hold a\n    // forked stream buffer for nothing.\n    const completedCacheInvocations =\n      isPrivate || !isBuiltInCacheHandler(kind)\n        ? (workStore.completedCacheInvocations ??= new Map<\n            string,\n            Promise<SharedCacheResult>\n          >())\n        : undefined\n\n    resolvableSharedCacheResult.registerIn(\n      intraRequestPendingCacheInvocations,\n      serializedCacheKey,\n      completedCacheInvocations\n    )\n\n    // Cross-request deduplication lets concurrent requests for the same key\n    // share a single fill. Private caches are skipped in production, where they\n    // hold request-specific data that must not be shared across requests. In\n    // development they're persisted and keyed by the request's cookies and\n    // headers, so concurrent requests with identical request data should share\n    // a fill too; that request-scoped `cacheHandlerKey` keeps requests with\n    // different cookies or headers in separate entries.\n    const skipCrossRequestDedupe = isPrivate && !process.env.__NEXT_DEV_SERVER\n\n    try {\n      // The loop handles cross-request root param mismatches: when a\n      // cross-request joiner discovers that the leader's root params differ\n      // from its own, it retries with a recomputed cacheHandlerKey. The loop\n      // exits when stream is assigned (cross-request joiner match or leader\n      // path) or via early return (prerender-dynamic).\n      while (stream === undefined) {\n        const crossRequestPendingCacheInvocation = skipCrossRequestDedupe\n          ? undefined\n          : crossRequestPendingCacheInvocations.get(cacheHandlerKey)\n\n        if (crossRequestPendingCacheInvocation) {\n          const cacheSignal = getCacheSignal(workUnitStore)\n          cacheSignal?.beginRead()\n\n          debug?.('joining pending cross-request invocation', cacheHandlerKey)\n          const sharedCacheResult = await crossRequestPendingCacheInvocation\n\n          if (sharedCacheResult.type === 'cached') {\n            // Root param verification: wait for metadata, then check key. MUST\n            // happen before fork() — if key mismatches, we retry without having\n            // used the stream.\n            const metadata = await sharedCacheResult.entry.pendingMetadata\n\n            // Ensure known root param names are up-to-date before verifying the\n            // key, since the leader's save path may not have updated them yet\n            // at this point.\n            if (metadata.readRootParamNames) {\n              addKnownRootParamNames(id, metadata.readRootParamNames)\n            }\n\n            const updatedRootParamNames = knownRootParamsByFunctionId.get(id)\n            if (updatedRootParamNames && rootParams) {\n              const newCacheHandlerKey =\n                cacheHandlerKeyBase +\n                computeRootParamsCacheKeySuffix(\n                  rootParams,\n                  updatedRootParamNames\n                )\n\n              if (newCacheHandlerKey !== cacheHandlerKey) {\n                debug?.(\n                  'cross-request root param mismatch, retrying',\n                  cacheHandlerKey,\n                  '→',\n                  newCacheHandlerKey\n                )\n                cacheSignal?.endRead()\n                cacheHandlerKey = newCacheHandlerKey\n                continue // stream is not used → retry with new key\n              }\n            }\n\n            // Key matches — safe to fork.\n            debug?.(\n              'cross-request invocation matched, forking result',\n              cacheHandlerKey\n            )\n            cacheSignal?.endRead()\n            stream = sharedCacheResult.entry.fork()\n            maybePropagateCacheEntryMetadata(cacheContext, metadata)\n\n            // The cross-request leader belongs to a different request with its\n            // own RDC. Save to this request's RDC so its final prerender can\n            // resume from the entry.\n            saveSharedCacheEntryToResumeDataCache(\n              serializedCacheKey,\n              sharedCacheResult.entry,\n              resumeDataCache\n            )\n\n            // Resolve for intra-request joiners in this request. They get\n            // a fork from the same SharedCacheEntry.\n            resolvableSharedCacheResult.resolve(sharedCacheResult)\n            break\n          } else {\n            // prerender-dynamic — same root param check before hanging\n            const updatedRootParamNames = knownRootParamsByFunctionId.get(id)\n            if (updatedRootParamNames && rootParams) {\n              const newCacheHandlerKey =\n                cacheHandlerKeyBase +\n                computeRootParamsCacheKeySuffix(\n                  rootParams,\n                  updatedRootParamNames\n                )\n\n              if (newCacheHandlerKey !== cacheHandlerKey) {\n                debug?.(\n                  'cross-request root param mismatch, retrying',\n                  cacheHandlerKey,\n                  '→',\n                  newCacheHandlerKey\n                )\n                cacheSignal?.endRead()\n                cacheHandlerKey = newCacheHandlerKey\n                continue\n              }\n            }\n\n            debug?.(\n              'cross-request invocation is prerender-dynamic',\n              cacheHandlerKey\n            )\n            if (resumeDataCache?.mutable) {\n              resumeDataCache.dynamicCacheKeys.add(serializedCacheKey)\n            }\n            cacheSignal?.endRead()\n            resolvableSharedCacheResult.resolve(sharedCacheResult)\n            return sharedCacheResult.hangingPromise\n          }\n        }\n\n        // No pending cross-request invocation — become the leader.\n        if (!skipCrossRequestDedupe) {\n          debug?.(\n            'registering as cross-request invocation leader',\n            cacheHandlerKey\n          )\n          resolvableSharedCacheResult.registerIn(\n            crossRequestPendingCacheInvocations,\n            cacheHandlerKey\n          )\n        }\n\n        const cacheSignal = getCacheSignal(workUnitStore)\n        if (cacheSignal) {\n          // Either the cache handler or the generation can be using I/O at this\n          // point. We need to track when they start and when they complete.\n          cacheSignal.beginRead()\n        }\n\n        const lazyRefreshTags = workStore.refreshTagsByCacheKind.get(kind)\n\n        if (lazyRefreshTags && !isResolvedLazyResult(lazyRefreshTags)) {\n          await lazyRefreshTags\n        }\n\n        let entry: CacheEntry | undefined\n\n        // We ignore existing cache entries when force revalidating.\n        if (cacheHandler && !shouldForceRevalidate(workStore, workUnitStore)) {\n          entry = await cacheHandler.get(cacheHandlerKey, implicitTags)\n\n          // Check if this is a redirect entry (coarse key → specific key).\n          // Redirect entries have private tags encoding the root param names\n          // (one tag per param name, prefixed with _N_RP_).\n          if (entry && rootParams) {\n            const paramNames = new Set<string>()\n            for (const tag of entry.tags) {\n              if (tag.startsWith(NEXT_CACHE_ROOT_PARAM_TAG_ID)) {\n                paramNames.add(tag.slice(NEXT_CACHE_ROOT_PARAM_TAG_ID.length))\n              }\n            }\n            if (paramNames.size > 0) {\n              addKnownRootParamNames(id, paramNames)\n              cacheHandlerKey =\n                cacheHandlerKeyBase +\n                computeRootParamsCacheKeySuffix(rootParams, paramNames)\n              entry = await cacheHandler.get(cacheHandlerKey, implicitTags)\n            }\n          }\n        }\n\n        if (entry) {\n          let implicitTagsExpiration = 0\n\n          if (workUnitStore.implicitTags) {\n            const lazyExpiration =\n              workUnitStore.implicitTags.expirationsByCacheKind.get(kind)\n\n            if (lazyExpiration) {\n              const expiration = isResolvedLazyResult(lazyExpiration)\n                ? lazyExpiration.value\n                : await lazyExpiration\n\n              // If a cache handler returns an expiration time of Infinity, it\n              // signals to Next.js that it handles checking cache entries for\n              // staleness based on the expiration of the implicit tags passed\n              // into the `get` method. In this case, we keep the default of 0,\n              // which means that the implicit tags are not considered expired.\n              if (expiration < Infinity) {\n                implicitTagsExpiration = expiration\n              }\n            }\n          }\n\n          if (\n            shouldDiscardCacheEntry(\n              entry,\n              workStore,\n              workUnitStore,\n              implicitTags,\n              implicitTagsExpiration\n            )\n          ) {\n            debug?.('discarding expired entry', cacheHandlerKey)\n            entry = undefined\n          }\n        }\n\n        const currentTime = performance.timeOrigin + performance.now()\n        if (\n          entry !== undefined &&\n          (entry.revalidate === 0 || entry.expire < MIN_PRERENDERABLE_EXPIRE)\n        ) {\n          switch (workUnitStore.type) {\n            case 'prerender':\n              // In a Dynamic I/O prerender, if the cache entry has revalidate:\n              // 0 or if the expire time is under 5 minutes, then we consider\n              // this cache entry dynamic as it's not worth generating static\n              // pages for such data. It's better to leave a dynamic hole that\n              // can be filled in during the resume with a potentially cached\n              // entry.\n              if (entry.revalidate === 0) {\n                debug?.(\n                  'omitting entry',\n                  cacheHandlerKey,\n                  'from static shell due to revalidate: 0'\n                )\n              } else {\n                debug?.(\n                  'omitting entry',\n                  cacheHandlerKey,\n                  'from static shell due to short expire value:',\n                  entry.expire\n                )\n              }\n              if (cacheSignal) {\n                cacheSignal.endRead()\n              }\n\n              // The entry is only excluded from *static* prerenders — the\n              // 'prerender-runtime' case below serves it — so a runtime\n              // prefetch would include this content.\n              const hangingPromise = makeRuntimeHangingPromise<never>(\n                workUnitStore.renderSignal,\n                workStore.route,\n                'dynamic \"use cache\"',\n                workUnitStore\n              )\n              debug?.('leader resolved as prerender-dynamic', cacheHandlerKey)\n              resolvableSharedCacheResult.resolve({\n                type: 'prerender-dynamic',\n                hangingPromise,\n              })\n              return hangingPromise\n            case 'request': {\n              if (process.env.NODE_ENV === 'development') {\n                // A short-lived entry is a dynamic hole, excluded from the\n                // static shell, so we end the cache signal read here (the\n                // prerender case does the same) to avoid this cache hit being\n                // considered a cache miss when checking for pending cache reads\n                // at staged rendering task boundaries. The value is deferred to\n                // the runtime stage.\n                if (cacheSignal && !cacheSignalReadEnded) {\n                  cacheSignal.endRead()\n                  cacheSignalReadEnded = true\n                }\n\n                await makeDevtoolsIOAwarePromise(\n                  undefined,\n                  workUnitStore,\n                  RENDER_STAGES_BY_DATA_KIND.sessionData\n                )\n              }\n              break\n            }\n            case 'prerender-runtime':\n            case 'prerender-ppr':\n            case 'prerender-legacy':\n            case 'cache':\n            case 'private-cache':\n            case 'unstable-cache':\n            case 'generate-static-params':\n              break\n            default:\n              workUnitStore satisfies never\n          }\n        }\n\n        if (entry !== undefined && entry.stale < MIN_SHELL_STALE) {\n          switch (workUnitStore.type) {\n            case 'request': {\n              // Same as the resume data cache read path: the entry's stale\n              // time is short enough that it's excluded from shells, or, if\n              // it's below `MIN_PREFETCHABLE_STALE`, from prerenders\n              // entirely. A request store in `next start` never delays\n              // caches — shells are produced by separate (runtime)\n              // prerenders. In dev, the request render is also used to\n              // recover shells, so we delay the entry here to match.\n              if (process.env.NODE_ENV === 'development') {\n                // End the cache signal read (once, in case the expire block\n                // above already did) so the delayed value isn't counted as a\n                // pending read at a staged rendering boundary.\n                if (cacheSignal && !cacheSignalReadEnded) {\n                  cacheSignal.endRead()\n                  cacheSignalReadEnded = true\n                }\n                // An unprefetchable entry is excluded from prerenders, so it\n                // resolves in the dynamic stage. Otherwise, a dynamic request\n                // generally recovers a static shell, so the entry can resolve\n                // in the static link data stage. If we need to recover a\n                // session shell instead, as indicated by `needsSessionShell`,\n                // the entry must resolve after the session data stage that\n                // the shell includes.\n                let stage: AdvanceableRenderStage\n                if (entry.stale < MIN_PREFETCHABLE_STALE) {\n                  stage = RenderStage.Dynamic\n                } else if (workUnitStore.needsSessionShell) {\n                  stage = RENDER_STAGES_BY_DATA_KIND.runtimeLinkData\n                } else {\n                  stage = RENDER_STAGES_BY_DATA_KIND.staticLinkData\n                }\n                await makeDevtoolsIOAwarePromise(\n                  undefined,\n                  workUnitStore,\n                  stage\n                )\n              }\n              break\n            }\n            case 'prerender':\n            case 'prerender-runtime':\n            case 'prerender-ppr':\n            case 'prerender-legacy':\n            case 'cache':\n            case 'private-cache':\n            case 'unstable-cache':\n            case 'generate-static-params':\n              // A handler read in a prerender context is a cache-filling read.\n              // The stale exclusions for those are applied when the RDC is\n              // read in the final prerender, so there's nothing to do here.\n              break\n            default:\n              workUnitStore satisfies never\n          }\n        }\n\n        if (\n          entry === undefined ||\n          // In dev, the built-in default handler retains a short-`expire` entry\n          // for at least `MIN_PRERENDERABLE_EXPIRE`, both when used directly\n          // and when fronting a custom cache handler. Apply that same minimum\n          // here so the retained entry is served and re-warmed in the\n          // background (below), rather than blocking to regenerate it on every\n          // read. The entry's real `expire` is untouched, so staging still\n          // treats it as dynamic.\n          currentTime >\n            entry.timestamp +\n              (process.env.__NEXT_DEV_SERVER\n                ? Math.max(entry.expire, MIN_PRERENDERABLE_EXPIRE)\n                : entry.expire) *\n                1000 ||\n          (workStore.isStaticGeneration &&\n            currentTime > entry.timestamp + entry.revalidate * 1000)\n        ) {\n          // Miss. Generate a new result.\n\n          // If the cache entry is stale and we're prerendering, we don't want\n          // to use the stale entry since it would unnecessarily need to shorten\n          // the lifetime of the prerender. We're not time constrained here so\n          // we can re-generated it now.\n\n          // We need to run this inside a clean AsyncLocalStorage snapshot so\n          // that the cache generation cannot read anything from the context\n          // we're currently executing which might include request specific\n          // things like cookies() inside a React.cache().\n          // Note: It is important that we await at least once before this\n          // because it lets us pop out of any stack specific contexts as well -\n          // aka \"Sync\" Local Storage.\n\n          if (entry) {\n            if (currentTime > entry.timestamp + entry.expire * 1000) {\n              debug?.('entry is expired', cacheHandlerKey)\n            }\n\n            if (\n              workStore.isStaticGeneration &&\n              currentTime > entry.timestamp + entry.revalidate * 1000\n            ) {\n              debug?.('static generation, entry is stale', cacheHandlerKey)\n            }\n          }\n\n          if (cacheSignal && cacheSignalReadEnded) {\n            // A short-lived deferral above (a `revalidate` of zero or a short\n            // expire, or a short stale time) already ended this read. We're now\n            // regenerating the entry rather than serving it, and the generation\n            // ends the read again once its entry is collected. Re-begin the\n            // read here so the trailing `endRead` stays balanced instead of\n            // over-decrementing the cache signal.\n            cacheSignal.beginRead()\n            cacheSignalReadEnded = false\n          }\n\n          const result = await generateCacheEntry(\n            workStore,\n            cacheContext,\n            clientReferenceManifest,\n            encodedCacheKeyParts,\n            fn,\n            timeoutError,\n            deadlockError\n          )\n\n          if (result.type === 'prerender-dynamic') {\n            debug?.(\n              'leader resolved as prerender-dynamic (generation)',\n              cacheHandlerKey\n            )\n            if (resumeDataCache?.mutable) {\n              resumeDataCache.dynamicCacheKeys.add(serializedCacheKey)\n            }\n            resolvableSharedCacheResult.resolve(result)\n            return result.hangingPromise\n          }\n\n          const { stream: newStream, pendingCacheResult } = result\n\n          // Cross-request joiners derive their metadata from this promise. By\n          // default it's the collected result, but when we write to a cache\n          // handler we swap in a promise that resolves only after the write has\n          // landed, so a joiner that re-reads its recomputed key finds the\n          // entry.\n          let metadataSource: Promise<CollectedCacheResult> = pendingCacheResult\n\n          // When draft mode is enabled, we must not save the cache entry.\n          if (!workStore.isDraftMode) {\n            const savedCacheResult = saveToResumeDataCache(\n              resumeDataCache,\n              serializedCacheKey,\n              pendingCacheResult\n            )\n\n            if (cacheHandler) {\n              metadataSource = saveToCacheHandler(\n                cacheHandler,\n                workStore,\n                id,\n                cacheHandlerKeyBase,\n                savedCacheResult,\n                rootParams\n              )\n            }\n          }\n\n          debug?.('leader resolved with generated entry', cacheHandlerKey)\n\n          const pendingMetadata: Promise<CacheResultMetadata> =\n            metadataSource.then((collected) => ({\n              tags: collected.entry.tags,\n              revalidate: collected.entry.revalidate,\n              expire: collected.entry.expire,\n              stale: collected.entry.stale,\n              timestamp: collected.entry.timestamp,\n              hasExplicitRevalidate: collected.hasExplicitRevalidate,\n              hasExplicitExpire: collected.hasExplicitExpire,\n              readRootParamNames: collected.readRootParamNames,\n              dynamicNestedCacheError: collected.dynamicNestedCacheError,\n            }))\n\n          const sharedCacheEntry = new SharedCacheEntry(\n            newStream,\n            pendingMetadata\n          )\n          stream = sharedCacheEntry.fork()\n          resolvableSharedCacheResult.resolve({\n            type: 'cached',\n            entry: sharedCacheEntry,\n          })\n        } else {\n          const entryMetadata: CacheResultMetadata = {\n            tags: entry.tags,\n            revalidate: entry.revalidate,\n            expire: entry.expire,\n            stale: entry.stale,\n            timestamp: entry.timestamp,\n            readRootParamNames: knownRootParamsByFunctionId.get(id),\n            // For pre-existing entries from cache handlers we don't know\n            // whether they had explicit cache life values or not. But we only\n            // need this information during prerendering when we produce new\n            // entries, where the cache life of an inner cache may be propagated\n            // to the outer one. In that case we use the RDC. So it's safe to\n            // set this to undefined here.\n            hasExplicitRevalidate: undefined,\n            hasExplicitExpire: undefined,\n            // The same applies to the dynamic nested cache error.\n            dynamicNestedCacheError: undefined,\n          }\n\n          maybePropagateCacheEntryMetadata(cacheContext, entryMetadata)\n\n          // We want to return this stream, even if it's stale.\n          stream = entry.value\n\n          // If we have a mutable resume data cache, we need to clone the entry\n          // and add it to the resume data cache.\n          if (resumeDataCache?.mutable) {\n            const [entryLeft, entryRight] = cloneCacheEntry(entry)\n            if (cacheSignal && !cacheSignalReadEnded) {\n              stream = createTrackedReadableStream(entryLeft.value, cacheSignal)\n            } else {\n              // The read was already ended for a short-lived deferral (or there\n              // is no cacheSignal), so serve a plain stream.\n              stream = entryLeft.value\n            }\n\n            // The RDC is per-page and root params are fixed within a page, so\n            // we always use the coarse key (without root param suffix).\n            resumeDataCache.cache.set(\n              serializedCacheKey,\n              Promise.resolve({\n                entry: entryRight,\n                hasExplicitRevalidate: entryMetadata.hasExplicitRevalidate,\n                hasExplicitExpire: entryMetadata.hasExplicitExpire,\n                readRootParamNames: entryMetadata.readRootParamNames,\n                dynamicNestedCacheError: entryMetadata.dynamicNestedCacheError,\n              })\n            )\n          } else if (!cacheSignalReadEnded) {\n            // If we're not regenerating we need to signal that we've finished\n            // putting the entry into the cache scope at this point. Otherwise\n            // we do that inside generateCacheEntry. (Skipped when the read was\n            // already ended for a short-lived deferral.)\n            cacheSignal?.endRead()\n          }\n\n          debug?.('leader resolved with cache handler hit', cacheHandlerKey)\n\n          const sharedCacheEntry = new SharedCacheEntry(\n            stream,\n            Promise.resolve(entryMetadata)\n          )\n          stream = sharedCacheEntry.fork()\n          resolvableSharedCacheResult.resolve({\n            type: 'cached',\n            entry: sharedCacheEntry,\n          })\n\n          // Trigger a background revalidation when the entry is stale (past its\n          // `revalidate`), so the next read gets a fresh value without blocking\n          // this one. Development additionally re-warms on every dynamic\n          // request render in two cases where the dev in-memory entry would\n          // otherwise read back as fresh, so a subsequent reload still shows a\n          // fresh value. The first is with the in-memory cache disabled\n          // (`cacheMaxMemorySize: 0`), where built-in entries keep their\n          // resolved (potentially non-dynamic) cache life. The second is a\n          // short-`expire` entry (an explicit dynamic or client-only cache,\n          // e.g. `cacheLife({ expire: 0 })`), which is retained for at least\n          // `MIN_PRERENDERABLE_EXPIRE` so it is served from the cache; this\n          // also covers custom handlers, re-executing and writing through to\n          // the backing.\n          let shouldTriggerBackgroundRevalidation =\n            currentTime > entry.timestamp + entry.revalidate * 1000\n          if (\n            !shouldTriggerBackgroundRevalidation &&\n            process.env.__NEXT_DEV_SERVER &&\n            (entry.expire < MIN_PRERENDERABLE_EXPIRE ||\n              (isMemoryCacheDisabled() && !isCustomCacheHandler(kind)))\n          ) {\n            switch (workUnitStore.type) {\n              case 'request':\n                shouldTriggerBackgroundRevalidation = true\n                break\n              case 'cache':\n              case 'private-cache':\n              case 'prerender':\n              case 'prerender-runtime':\n              case 'prerender-ppr':\n              case 'prerender-legacy':\n              case 'unstable-cache':\n              case 'generate-static-params':\n                break\n              default:\n                workUnitStore satisfies never\n            }\n          }\n\n          if (shouldTriggerBackgroundRevalidation) {\n            const revalidateCacheHandlerKey = cacheHandlerKey\n            const revalidatePromise = generateCacheEntry(\n              workStore,\n              // The background revalidation preserves the outer store for\n              // reading (e.g. implicitTags) but skips propagation of cache life\n              // and tags back to the outer scope.\n              {\n                ...cacheContext,\n                skipPropagation: true,\n              },\n              clientReferenceManifest,\n              encodedCacheKeyParts,\n              fn,\n              timeoutError,\n              deadlockError\n            )\n              .then(async (result) => {\n                if (result.type === 'cached') {\n                  const { stream: ignoredStream, pendingCacheResult } = result\n\n                  const savedCacheResult = saveToResumeDataCache(\n                    resumeDataCache,\n                    serializedCacheKey,\n                    pendingCacheResult\n                  )\n\n                  if (cacheHandler) {\n                    saveToCacheHandler(\n                      cacheHandler,\n                      workStore,\n                      id,\n                      cacheHandlerKeyBase,\n                      savedCacheResult,\n                      rootParams\n                    )\n                  }\n\n                  await ignoredStream.cancel()\n                }\n              })\n              .catch((error) => {\n                debug?.(\n                  'background cache revalidation failed for',\n                  revalidateCacheHandlerKey,\n                  error\n                )\n              })\n            workStore.pendingRevalidateWrites ??= []\n            workStore.pendingRevalidateWrites.push(revalidatePromise)\n          }\n        }\n      }\n    } catch (error) {\n      resolvableSharedCacheResult.reject(error)\n      throw error\n    }\n  }\n\n  // Logs are replayed even if it's a hit - to ensure we see them on the client eventually.\n  // If we didn't then the client wouldn't see the logs if it was seeded from a prewarm that\n  // never made it to the client. However, this also means that you see logs even when the\n  // cached function isn't actually re-executed. We should instead ensure prewarms always\n  // make it to the client. Another issue is that this will cause double logging in the\n  // server terminal. Once while generating the cache entry and once when replaying it on\n  // the server, which is required to pick it up for replaying again on the client.\n  const replayConsoleLogs = true\n\n  const serverConsumerManifest = {\n    // moduleLoading must be null because we don't want to trigger preloads of ClientReferences\n    // to be added to the consumer. Instead, we'll wait for any ClientReference to be emitted\n    // which themselves will handle the preloading.\n    moduleLoading: null,\n    moduleMap: isEdgeRuntime\n      ? clientReferenceManifest.edgeRscModuleMapping\n      : clientReferenceManifest.rscModuleMapping,\n    serverModuleMap: getServerModuleMap(),\n  }\n\n  return createFromReadableStream(stream, {\n    findSourceMapURL,\n    serverConsumerManifest,\n    temporaryReferences,\n    replayConsoleLogs,\n    environmentName: 'Cache',\n  })\n}\n\n/**\n * Returns `true` if the `'use cache'` function is the page component itself,\n * or `generateMetadata`/`generateViewport` in a page file.\n */\nfunction isPageSegmentFunction(\n  args: any[]\n): args is [UseCachePageProps, ...unknown[]] {\n  const [maybeProps] = args\n\n  return (\n    maybeProps !== null &&\n    typeof maybeProps === 'object' &&\n    (maybeProps as UseCachePageProps).$$isPage === true\n  )\n}\n\n/**\n * Returns `true` if the `'use cache'` function is the layout component itself,\n * or `generateMetadata`/`generateViewport` in a layout file.\n */\nfunction isLayoutSegmentFunction(\n  args: any[]\n): args is [UseCacheLayoutProps, ...unknown[]] {\n  const [maybeProps] = args\n\n  return (\n    maybeProps !== null &&\n    typeof maybeProps === 'object' &&\n    (maybeProps as UseCacheLayoutProps).$$isLayout === true\n  )\n}\n\nfunction shouldForceRevalidate(\n  workStore: WorkStore,\n  workUnitStore: WorkUnitStore\n): boolean {\n  if (workStore.isOnDemandRevalidate || workStore.isDraftMode) {\n    return true\n  }\n\n  if (process.env.__NEXT_DEV_SERVER) {\n    switch (workUnitStore.type) {\n      case 'request':\n        return workUnitStore.headers.get('cache-control') === 'no-cache'\n      case 'cache':\n      case 'private-cache':\n        return workUnitStore.forceRevalidate\n      case 'prerender-runtime':\n      case 'prerender':\n      case 'prerender-client':\n      case 'validation-client':\n      case 'prerender-ppr':\n      case 'prerender-legacy':\n      case 'unstable-cache':\n      case 'generate-static-params':\n        break\n      default:\n        workUnitStore satisfies never\n    }\n  }\n\n  return false\n}\n\nfunction shouldDiscardCacheEntry(\n  entry: Pick<CacheEntry, 'tags' | 'timestamp'>,\n  workStore: WorkStore,\n  workUnitStore: WorkUnitStore,\n  implicitTags: string[],\n  implicitTagsExpiration: number\n): boolean {\n  // If the cache entry was created before any of the implicit tags were\n  // revalidated last, we need to discard it.\n  if (entry.timestamp <= implicitTagsExpiration) {\n    debug?.(\n      'entry was created at',\n      entry.timestamp,\n      'before implicit tags were revalidated at',\n      implicitTagsExpiration\n    )\n\n    return true\n  }\n\n  // During prerendering, we ignore recently revalidated tags. In dev mode, we\n  // can assume that the dynamic dev rendering will have discarded and recreated\n  // the affected cache entries, and we don't want to discard those again during\n  // the prerender validation. During build-time prerendering, there will never\n  // be any pending revalidated tags.\n  switch (workUnitStore.type) {\n    case 'prerender':\n      return false\n    case 'prerender-runtime':\n    case 'prerender-client':\n    case 'validation-client':\n    case 'prerender-ppr':\n    case 'prerender-legacy':\n    case 'request':\n    case 'cache':\n    case 'private-cache':\n    case 'unstable-cache':\n    case 'generate-static-params':\n      break\n    default:\n      workUnitStore satisfies never\n  }\n\n  // If the cache entry contains revalidated tags that the cache handler might\n  // not know about yet, we need to discard it.\n  if (\n    entry.tags.some((tag) =>\n      isRevalidatedAfter(tag, entry.timestamp, workStore)\n    )\n  ) {\n    return true\n  }\n\n  // Finally, if any of the implicit tags have been revalidated recently, we\n  // also need to discard the cache entry.\n  if (\n    implicitTags.some((tag) =>\n      isRevalidatedAfter(tag, entry.timestamp, workStore)\n    )\n  ) {\n    return true\n  }\n\n  return false\n}\n\n/**\n * Whether `tag` was revalidated after an entry created at `entryTimestamp`,\n * which makes that entry stale. An entry produced after the revalidation\n * already reflects it and is still usable.\n */\nfunction isRevalidatedAfter(\n  tag: string,\n  entryTimestamp: number,\n  workStore: WorkStore\n): boolean {\n  const {\n    previouslyRevalidatedTags,\n    pendingRevalidatedTags,\n    requestStartTime,\n  } = workStore\n\n  // Was the tag previously revalidated (e.g. by a redirecting server action)?\n  // That happened in an earlier request and carries no timestamp of its own, so\n  // it counts as having happened when this request started.\n  if (\n    entryTimestamp <= requestStartTime &&\n    previouslyRevalidatedTags.includes(tag)\n  ) {\n    debug?.('tag', tag, 'was previously revalidated')\n\n    return true\n  }\n\n  // It could also have been revalidated by the currently running server action.\n  // In this case the revalidation might not have been fully propagated by a\n  // remote cache handler yet, so we read it from the pending tags in the work\n  // store.\n  if (\n    pendingRevalidatedTags?.some(\n      (item) => item.tag === tag && item.revalidatedAt > entryTimestamp\n    )\n  ) {\n    debug?.('tag', tag, 'was just revalidated')\n\n    return true\n  }\n\n  return false\n}\n"],"names":["cache","SharedCacheEntry","constructor","stream","pendingMetadata","fork","forked","remaining","tee","ignoreReject","ResolvableSharedCacheResult","registerIn","map","key","retentionMap","set","deferred","promise","registrations","push","resolve","result","type","entry","then","cleanupAndRetain","cleanup","reject","error","catch","delete","createPromiseWithResolvers","crossRequestPendingCacheInvocations","Map","isEdgeRuntime","process","env","NEXT_RUNTIME","debug","NEXT_PRIVATE_DEBUG_CACHE","console","bind","undefined","filterStackFrame","NODE_ENV","require","filterStackFrameDEV","findSourceMapURL","findSourceMapURLDEV","nestedCacheZeroRevalidateErrorMessage","nestedCacheShortExpireErrorMessage","knownRootParamsByFunctionId","addKnownRootParamNames","id","names","existing","get","name","add","created","Set","computeRootParamsCacheKeySuffix","rootParams","paramNames","size","JSON","stringify","sort","paramName","COOKIES_EXCLUDED_FROM_PRIVATE_CACHE_KEY","NEXT_INSTANT_TEST_COOKIE","HEADERS_EXCLUDED_FROM_PRIVATE_CACHE_KEY","computePrivateCacheKeyRequestSuffix","cookies","headers","relevantCookies","getAll","filter","cookie","has","value","nameA","nameB","relevantHeaders","entries","length","saveToResumeDataCache","resumeDataCache","serializedCacheKey","pendingCacheResult","mutable","split","clonePendingCacheResult","savedCacheResult","getNthCacheResult","rdcResult","saveSharedCacheEntryToResumeDataCache","sharedCacheEntry","metadata","tags","revalidate","expire","stale","timestamp","readRootParamNames","hasExplicitRevalidate","hasExplicitExpire","dynamicNestedCacheError","serveJoinedCacheEntry","cacheContext","cacheSignal","endRead","maybePropagateCacheEntryMetadata","saveToCacheHandler","cacheHandler","workStore","cacheHandlerKeyBase","combinedSetPromise","collectedResult","fullEntry","rootParamNames","setPromises","coarseEntry","specificKey","Promise","rootParamTags","NEXT_CACHE_ROOT_PARAM_TAG_ID","ReadableStream","start","controller","enqueue","Uint8Array","close","all","pendingRevalidateWrites","generateCacheEntry","clientReferenceManifest","encodedArguments","fn","timeoutError","deadlockError","runInCleanSnapshot","generateCacheEntryWithRestoredWorkStore","workAsyncStorage","run","generateCacheEntryWithCacheContext","createUseCacheStore","defaultCacheLife","kind","outerWorkUnitStore","phase","implicitTags","explicitRevalidate","explicitExpire","explicitStale","hmrRefreshHash","getHmrRefreshHash","isHmrRefresh","serverComponentsHmrCache","getServerComponentsHmrCache","forceRevalidate","shouldForceRevalidate","draftMode","getDraftModeProviderForCacheScope","__NEXT_DEV_SERVER","HeadersAdapter","fresh","RequestCookiesAdapter","outerOwnerStack","useCacheOrRequestStore","captureOuterOwnerStack","workUnitStore","getClientReact","getServerReact","capturedOwnerStack","captureOwnerStack","parentOuterOwnerStack","getUseCacheFillTimeoutMs","workUnitStoreType","useCacheTimeout","staticPageGenerationTimeout","effectiveTimeout","Math","min","cacheLifeProfiles","default","cacheStore","workUnitAsyncStorage","dynamicAccessAsyncStorage","abortController","AbortController","generateCacheEntryImpl","propagateCacheLifeAndTagsToRevalidateStore","revalidateStore","outerTags","tag","includes","propagateCacheStaleTimeToRequestStore","requestStore","propagateCacheEntryMetadata","MIN_PRERENDERABLE_EXPIRE","collectResult","savedStream","innerCacheStore","startTime","errors","buffer","reader","getReader","read","done","idx","bufferStream","pull","invalidDynamicUsageError","collectedTags","isPrivateCacheInDev","Boolean","forceDynamicCacheLifeInDev","collectedRevalidate","collectedExpire","collectedStale","collected","skipPropagation","getCacheSignal","temporaryReferences","createServerTemporaryReferenceSet","args","decodeReply","getServerModuleMap","decodeReplyFromAsyncIterable","Symbol","asyncIterator","renderSignal","aborted","addEventListener","once","performance","timeOrigin","now","resultPromise","createLazyResult","handleError","createReactServerErrorHandler","isBuildTimePrerendering","reactServerErrorsByDigest","Log","devTimeoutAbortController","timeoutAbortController","timer","setTimeout","abort","dynamicAccessAbortSignal","getStore","signal","abortSignal","AbortSignal","any","prelude","prerender","clientModules","environmentName","onError","reason","clearTimeout","didTimeout","hangingPromise","makeRuntimeHangingPromise","route","stagedRendering","stageAtReadStart","currentStage","RenderStage","Dynamic","devRenderAbortController","fillTimeoutMs","fillDeadlineAt","devRenderTimeoutTimer","renderToReadableStream","Error","digest","createDigestWithErrorCode","stringHash","message","stack","toString","setupProbeScheduler","outerRequestStore","onProbeCompleted","InvariantError","returnStream","finally","cloneCacheResult","entryA","entryB","cloneCacheEntry","i","encodeFormData","formData","stringValue","arrayBuffer","byteLength","String","fromCodePoint","Uint16Array","createTrackedReadableStream","boundArgsLength","originalFn","isPrivate","makeUntrackedHangingPromise","useCacheProbeMode","getPrivateCacheHandler","handler","getCacheHandler","isCustomCacheHandler","tieredCacheHandler","getDevTieredCacheHandler","UseCacheTimeoutError","captureStackTrace","applyOwnerStack","UseCacheDeadlockError","wrapAsInvalidDynamicUsageError","expression","postponeWithTracking","dynamicTracking","throwToInterruptStaticGeneration","functionId","handlerKind","NestedDynamicUseCacheError","getClientReferenceManifest","buildId","deploymentId","hangingInputAbortSignal","createHangingInputAbortSignal","waitForStage","RENDER_STAGES_BY_DATA_KIND","sessionData","makeDevtoolsIOAwarePromise","isPageOrLayoutSegmentFunction","isPageSegmentFunction","params","outerParams","searchParams","outerSearchParams","otherOuterArgs","props","_innerParams","innerSearchParams","otherInnerArgs","apply","makeErroringSearchParamsForUseCache","isLayoutSegmentFunction","$$isLayout","outerSlots","innerSlots","encryptedBoundArgs","shift","boundArgs","decryptActionBoundArgs","Array","isArray","unshift","createClientTemporaryReferenceSet","cacheKeyParts","encodeCacheKeyParts","encodeReply","encodedCacheKeyParts","dynamicAccessAbortController","probeTimeoutMs","timeoutMs","cancel","probeTimeoutTimer","race","_","knownRootParamNames","cacheHandlerKey","cacheSignalReadEnded","getResumeDataCache","dynamicCacheKeys","beginRead","rdcEntry","some","isRevalidatedAfter","shouldReportNestedCacheError","cause","MIN_SHELL_STALE","isPrefetchable","MIN_PREFETCHABLE_STALE","prerenderStore","postShellStage","staticLinkData","runtimeLinkData","finalStage","makeStageHangingPromise","makeDynamicHangingPromise","stage","needsSessionShell","streamA","streamB","warn","pendingInvocation","pendingCacheInvocations","completedInvocation","completedCacheInvocations","joinedInvocation","sharedCacheResult","shouldDiscardCacheEntry","resolvableSharedCacheResult","intraRequestPendingCacheInvocations","isBuiltInCacheHandler","skipCrossRequestDedupe","crossRequestPendingCacheInvocation","updatedRootParamNames","newCacheHandlerKey","lazyRefreshTags","refreshTagsByCacheKind","isResolvedLazyResult","startsWith","slice","implicitTagsExpiration","lazyExpiration","expirationsByCacheKind","expiration","Infinity","currentTime","max","isStaticGeneration","newStream","metadataSource","isDraftMode","entryMetadata","entryLeft","entryRight","shouldTriggerBackgroundRevalidation","isMemoryCacheDisabled","revalidateCacheHandlerKey","revalidatePromise","ignoredStream","replayConsoleLogs","serverConsumerManifest","moduleLoading","moduleMap","edgeRscModuleMapping","rscModuleMapping","serverModuleMap","createFromReadableStream","maybeProps","$$isPage","isOnDemandRevalidate","entryTimestamp","previouslyRevalidatedTags","pendingRevalidatedTags","requestStartTime","item","revalidatedAt"],"mappings":";;;;+BAkrDsBA;;;eAAAA;;;wBA3qDf;wBAKA;wBACmB;0CAIO;8CAmB1B;uCAUA;oCAOA;4BAGgC;gCACR;oCAIxB;qCACmC;mEACnB;2BAKhB;4BACsC;0BAQtC;iCAEyB;kCACS;gCAIlC;yBAIA;gCAKA;kCAKA;8BAIA;4BAGgD;mDACb;iCAKnC;6DACc;uCAC0B;sCACJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmF3C;;;;CAIC,GACD,MAAMC;IAUJC,YACEC,MAAkC,EAClCC,eAA6C,CAC7C;QACA,IAAI,CAACD,MAAM,GAAGA;QACd,IAAI,CAACC,eAAe,GAAGA;IACzB;IAEA;;;;G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