{"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  getRenderResumeDataCache,\n  getPrerenderResumeDataCache,\n  workUnitAsyncStorage,\n  getDraftModeProviderForCacheScope,\n  getCacheSignal,\n  isHmrRefresh,\n  getServerComponentsHmrCache,\n} from '../app-render/work-unit-async-storage.external'\n\nimport {\n  getRuntimeStage,\n  makeDevtoolsIOAwarePromise,\n  makeHangingPromise,\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 { createReactServerErrorHandler } from '../app-render/create-error-handler'\nimport { DYNAMIC_EXPIRE, RUNTIME_PREFETCH_DYNAMIC_STALE } from './constants'\nimport { NEXT_CACHE_ROOT_PARAM_TAG_ID } from '../../lib/constants'\nimport type { CacheHandler } from '../lib/cache-handlers/types'\nimport { getCacheHandler } from './handlers'\nimport { UseCacheTimeoutError } 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 { PrerenderResumeDataCache } 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 { RenderStage } from '../app-render/staged-rendering'\nimport * as Log from '../../build/output/log'\n\ninterface PrivateCacheContext {\n  readonly kind: 'private'\n  readonly outerWorkUnitStore:\n    | RequestStore\n    | PrivateUseCacheStore\n    | PrerenderStoreModernRuntime\n  readonly skipPropagation: boolean\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}\n\ntype CacheContext = PrivateCacheContext | PublicCacheContext\n\ntype 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\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\nfunction saveToResumeDataCache(\n  prerenderResumeDataCache: PrerenderResumeDataCache | null,\n  serializedCacheKey: string,\n  pendingCacheResult: Promise<CollectedCacheResult>\n): Promise<CollectedCacheResult> {\n  if (!prerenderResumeDataCache) {\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  prerenderResumeDataCache.cache.set(serializedCacheKey, rdcResult)\n\n  return savedCacheResult\n}\n\nfunction saveToCacheHandler(\n  cacheHandler: CacheHandler,\n  workStore: WorkStore,\n  id: string,\n  serializedCacheKey: string,\n  savedCacheResult: Promise<CollectedCacheResult>,\n  rootParams: Params | undefined\n): void {\n  const pendingCoarseEntry = savedCacheResult.then((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    if (rootParamNames && rootParamNames.size > 0 && rootParams) {\n      const specificKey =\n        serializedCacheKey +\n        computeRootParamsCacheKeySuffix(rootParams, rootParamNames)\n\n      const specificSetPromise = cacheHandler.set(\n        specificKey,\n        Promise.resolve(fullEntry)\n      )\n      workStore.pendingRevalidateWrites ??= []\n      workStore.pendingRevalidateWrites.push(specificSetPromise)\n\n      // Return a redirect entry for the coarse key. On a cold server (empty\n      // knownRootParamsByFunctionId), this entry's tags tell us which root\n      // params to include in the specific key for the follow-up lookup.\n\n      const rootParamTags = [...rootParamNames].map(\n        (paramName) => NEXT_CACHE_ROOT_PARAM_TAG_ID + paramName\n      )\n\n      return {\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    return fullEntry\n  })\n\n  const promise = cacheHandler.set(serializedCacheKey, pendingCoarseEntry)\n  workStore.pendingRevalidateWrites ??= []\n  workStore.pendingRevalidateWrites.push(promise)\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) {\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  )\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) {\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  )\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      headers: outerWorkUnitStore.headers,\n      cookies: outerWorkUnitStore.cookies,\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    }\n  }\n}\n\nfunction assertDefaultCacheLife(\n  defaultCacheLife: CacheLife | undefined\n): asserts defaultCacheLife is Required<CacheLife> {\n  if (\n    !defaultCacheLife ||\n    defaultCacheLife.revalidate == null ||\n    defaultCacheLife.expire == null ||\n    defaultCacheLife.stale == null\n  ) {\n    throw new InvariantError(\n      'A default cacheLife profile must always be provided.'\n    )\n  }\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) {\n  if (!workStore.cacheLifeProfiles) {\n    throw new InvariantError('cacheLifeProfiles should always be provided.')\n  }\n  const defaultCacheLife = workStore.cacheLifeProfiles['default']\n  assertDefaultCacheLife(defaultCacheLife)\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    )\n  )\n}\n\nfunction propagateCacheLifeAndTagsToRevalidateStore(\n  revalidateStore: RevalidateStore,\n  entry: CacheEntry\n): void {\n  const outerTags = (revalidateStore.tags ??= [])\n\n  for (const tag of entry.tags) {\n    if (!outerTags.includes(tag)) {\n      outerTags.push(tag)\n    }\n  }\n\n  if (revalidateStore.stale > entry.stale) {\n    revalidateStore.stale = entry.stale\n  }\n\n  if (revalidateStore.revalidate > entry.revalidate) {\n    revalidateStore.revalidate = entry.revalidate\n  }\n\n  if (revalidateStore.expire > entry.expire) {\n    revalidateStore.expire = entry.expire\n  }\n}\n\nfunction propagateCacheStaleTimeToRequestStore(\n  requestStore: RequestStore,\n  entry: CacheEntry\n): void {\n  if (requestStore.stale !== undefined && requestStore.stale > entry.stale) {\n    requestStore.stale = entry.stale\n  }\n}\n\nfunction propagateCacheEntryMetadata(\n  cacheContext: CacheContext,\n  entry: CacheEntry,\n  readRootParamNames: ReadonlySet<string> | undefined\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          entry\n        )\n        break\n      case 'request':\n        propagateCacheStaleTimeToRequestStore(\n          cacheContext.outerWorkUnitStore,\n          entry\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 (readRootParamNames) {\n          for (const paramName of readRootParamNames) {\n            cacheContext.outerWorkUnitStore.readRootParamNames.add(paramName)\n          }\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          entry\n        )\n        break\n      case 'request':\n        propagateCacheStaleTimeToRequestStore(\n          cacheContext.outerWorkUnitStore,\n          entry\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  entry: CacheEntry,\n  readRootParamNames: ReadonlySet<string> | undefined\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, entry, readRootParamNames)\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\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  // If cacheLife() was used to set an explicit revalidate time we use that.\n  // Otherwise, we use the lowest of all inner fetch()/unstable_cache() or nested \"use cache\".\n  // If they're lower than our default.\n  const collectedRevalidate =\n    innerCacheStore.explicitRevalidate !== undefined\n      ? innerCacheStore.explicitRevalidate\n      : innerCacheStore.revalidate\n  const collectedExpire =\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  if (!cacheContext.skipPropagation) {\n    maybePropagateCacheEntryMetadata(\n      cacheContext,\n      entry,\n      innerCacheStore.type === 'cache'\n        ? innerCacheStore.readRootParamNames\n        : undefined\n    )\n\n    const cacheSignal = getCacheSignal(cacheContext.outerWorkUnitStore)\n    if (cacheSignal) {\n      cacheSignal.endRead()\n    }\n  }\n\n  return {\n    entry,\n    hasExplicitRevalidate: innerCacheStore.explicitRevalidate !== undefined,\n    hasExplicitExpire: innerCacheStore.explicitExpire !== undefined,\n    readRootParamNames:\n      innerCacheStore.type === 'cache'\n        ? innerCacheStore.readRootParamNames\n        : undefined,\n  }\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): 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  let 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\n  switch (outerWorkUnitStore.type) {\n    case 'prerender-runtime':\n    case 'prerender':\n      const timeoutAbortController = new AbortController()\n      // If we're prerendering, we give you 50 seconds to fill a cache entry.\n      // Otherwise we assume you stalled on hanging input and de-opt. This needs\n      // to be lower than just the general timeout of 60 seconds.\n      const timer = setTimeout(() => {\n        workStore.invalidDynamicUsageError = timeoutError\n        timeoutAbortController.abort(timeoutError)\n      }, 50000)\n\n      const dynamicAccessAbortSignal =\n        dynamicAccessAsyncStorage.getStore()?.abortController.signal\n\n      const abortSignal = dynamicAccessAbortSignal\n        ? AbortSignal.any([\n            dynamicAccessAbortSignal,\n            outerWorkUnitStore.renderSignal,\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\n      if (timeoutAbortController.signal.aborted) {\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        const hangingPromise = makeHangingPromise<never>(\n          outerWorkUnitStore.renderSignal,\n          workStore.route,\n          'dynamic \"use cache\"'\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    case 'request':\n      // If we're filling caches for a staged render, make sure that\n      // it takes at least a task, so we'll always notice a cache miss between stages.\n      //\n      // TODO(restart-on-cache-miss): This is suboptimal.\n      // Ideally we wouldn't need to restart for microtasky caches,\n      // but the current logic for omitting short-lived caches only works correctly\n      // if we do a second render, so that's the best we can do until we refactor that.\n      if (\n        process.env.NODE_ENV === 'development' &&\n        outerWorkUnitStore.cacheSignal\n      ) {\n        await new Promise((resolve) => setTimeout(resolve))\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  )\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 cloneCacheEntry(entry: CacheEntry): [CacheEntry, CacheEntry] {\n  const [streamA, streamB] = entry.value.tee()\n  entry.value = streamA\n  const clonedEntry: CacheEntry = {\n    value: streamB,\n    timestamp: entry.timestamp,\n    revalidate: entry.revalidate,\n    expire: entry.expire,\n    stale: entry.stale,\n    tags: entry.tags,\n  }\n  return [entry, clonedEntry]\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    },\n    {\n      entry: entryB,\n      hasExplicitRevalidate: result.hasExplicitRevalidate,\n      hasExplicitExpire: result.hasExplicitExpire,\n      readRootParamNames: result.readRootParamNames,\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  // Private caches are currently only stored in the Resume Data Cache (RDC),\n  // and not in cache handlers.\n  const cacheHandler = isPrivate ? undefined : getCacheHandler(kind)\n\n  if (!isPrivate && !cacheHandler) {\n    throw new Error('Unknown cache handler: ' + kind)\n  }\n\n  const timeoutError = new UseCacheTimeoutError()\n  Error.captureStackTrace(timeoutError, cache)\n\n  const wrapAsInvalidDynamicUsageError = (\n    error: Error,\n    workStore: WorkStore\n  ) => {\n    Error.captureStackTrace(error, cache)\n    workStore.invalidDynamicUsageError ??= error\n\n    return error\n  }\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  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        return makeHangingPromise(\n          workUnitStore.renderSignal,\n          workStore.route,\n          expression\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          workStore\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          workStore\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        }\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          workStore\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 'prerender':\n      case 'prerender-runtime':\n      case 'prerender-ppr':\n      case 'prerender-legacy':\n      case 'request':\n      case 'cache':\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        }\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.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 read from\n        // Segments not using runtime prefetch resolve at EarlyRuntime,\n        // while runtime-prefetchable segments resolve at Runtime.\n        const stagedRendering = outerWorkUnitStore.stagedRendering\n        if (stagedRendering) {\n          await stagedRendering.waitForStage(getRuntimeStage(stagedRendering))\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. We pick the appropriate runtime stage based on\n          // whether we're in the early or late stages.\n          const stagedRendering = outerWorkUnitStore.stagedRendering\n          const stage = stagedRendering\n            ? getRuntimeStage(stagedRendering)\n            : RenderStage.Runtime\n          await makeDevtoolsIOAwarePromise(undefined, outerWorkUnitStore, stage)\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  // For private caches, which are allowed to read cookies, we still don't\n  // need to include the cookies in the cache key. This is because we don't\n  // store the cache entries in a cache handler, but 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, so it\n  // does not include any private caches. For runtime prefetches, the RDC is\n  // mutable, but only lives as long as the request, so the key does not\n  // need to include cookies.\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          return makeHangingPromise(\n            workUnitStore.renderSignal,\n            workStore.route,\n            'dynamic \"use cache\"'\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  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  // 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  const rootParams = workUnitStore.rootParams\n  const knownRootParamNames = knownRootParamsByFunctionId.get(id)\n  let cacheHandlerKey =\n    knownRootParamNames && rootParams\n      ? serializedCacheKey +\n        computeRootParamsCacheKeySuffix(rootParams, knownRootParamNames)\n      : serializedCacheKey\n\n  let stream: undefined | ReadableStream = undefined\n\n  // Get an immutable and mutable versions of the resume data cache.\n  const prerenderResumeDataCache = getPrerenderResumeDataCache(workUnitStore)\n  const renderResumeDataCache = getRenderResumeDataCache(workUnitStore)\n\n  const implicitTags = workUnitStore.implicitTags?.tags ?? []\n\n  if (renderResumeDataCache) {\n    const cacheSignal = getCacheSignal(workUnitStore)\n\n    if (cacheSignal) {\n      cacheSignal.beginRead()\n    }\n    const rdcEntry = renderResumeDataCache.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        if (\n          rdcResult.entry.tags.some((tag) =>\n            isRecentlyRevalidatedTag(tag, workStore)\n          ) ||\n          implicitTags.some((tag) => isRecentlyRevalidatedTag(tag, workStore))\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 < DYNAMIC_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 (rdcResult.hasExplicitRevalidate === false) {\n                  throw wrapAsInvalidDynamicUsageError(\n                    new Error(nestedCacheZeroRevalidateErrorMessage),\n                    workStore\n                  )\n                }\n                debug?.(\n                  'omitting entry',\n                  serializedCacheKey,\n                  'from static shell due to revalidate: 0'\n                )\n              } else {\n                if (rdcResult.hasExplicitExpire === false) {\n                  throw wrapAsInvalidDynamicUsageError(\n                    new Error(nestedCacheShortExpireErrorMessage),\n                    workStore\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              return makeHangingPromise(\n                workUnitStore.renderSignal,\n                workStore.route,\n                'dynamic \"use cache\"'\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                  getRuntimeStage(stagedRendering)\n                )\n              }\n              break\n            }\n            case 'request': {\n              if (process.env.NODE_ENV === 'development') {\n                if (\n                  rdcResult.entry.revalidate === 0 &&\n                  rdcResult.hasExplicitRevalidate === false\n                ) {\n                  throw wrapAsInvalidDynamicUsageError(\n                    new Error(nestedCacheZeroRevalidateErrorMessage),\n                    workStore\n                  )\n                }\n                if (\n                  rdcResult.entry.expire < DYNAMIC_EXPIRE &&\n                  rdcResult.hasExplicitExpire === false\n                ) {\n                  throw wrapAsInvalidDynamicUsageError(\n                    new Error(nestedCacheShortExpireErrorMessage),\n                    workStore\n                  )\n                }\n                // We delay the cache here so that it doesn't resolve in the static task --\n                // in a regular static prerender, it'd be a hanging promise, and we need to reflect that,\n                // so it has to resolve later.\n                // TODO(restart-on-cache-miss): Optimize this to avoid unnecessary restarts.\n                // We don't end the cache read here, so this will always appear as a cache miss in the static stage,\n                // and thus will cause a restart even if all caches are filled.\n                const stagedRendering = workUnitStore.stagedRendering\n                const stage = stagedRendering\n                  ? getRuntimeStage(stagedRendering)\n                  : RenderStage.Runtime\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        if (rdcResult.entry.stale < RUNTIME_PREFETCH_DYNAMIC_STALE) {\n          switch (workUnitStore.type) {\n            case 'prerender-runtime':\n              // In a runtime prerender, if the cache entry will become\n              // stale in less then 30 seconds, we consider this cache entry\n              // dynamic as it's not worth prefetching. It's better to leave\n              // a dynamic hole that can be filled during the navigation.\n              debug?.(\n                'omitting entry',\n                serializedCacheKey,\n                'from runtime shell due to short stale value:',\n                rdcResult.entry.stale\n              )\n              if (cacheSignal) {\n                cacheSignal.endRead()\n              }\n              return makeHangingPromise(\n                workUnitStore.renderSignal,\n                workStore.route,\n                'dynamic \"use cache\"'\n              )\n            case 'request': {\n              if (process.env.NODE_ENV === 'development') {\n                // We delay the cache here so that it doesn't resolve in the runtime phase --\n                // in a regular runtime prerender, it'd be a hanging promise, and we need to reflect that,\n                // so it has to resolve later.\n                // TODO(restart-on-cache-miss): Optimize this to avoid unnecessary restarts.\n                // We don't end the cache read here, so this will always appear as a cache miss in the runtime stage,\n                // and thus will cause a restart even if all caches are filled.\n                await makeDevtoolsIOAwarePromise(\n                  undefined,\n                  workUnitStore,\n                  RenderStage.Dynamic\n                )\n              }\n              break\n            }\n            case 'prerender':\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 (prerenderResumeDataCache) {\n          prerenderResumeDataCache.cache.set(serializedCacheKey, rdcEntry)\n        }\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(\n          cacheContext,\n          rdcResult.entry,\n          rdcResult.readRootParamNames\n        )\n\n        const [streamA, streamB] = rdcResult.entry.value.tee()\n        rdcResult.entry.value = streamB\n\n        if (cacheSignal) {\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          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 `allowEmptyStaticShell` is true, and thus a prefilled resume\n          // data cache was provided, then a cache miss means that params were\n          // part of the cache key. In this case, we can make this cache\n          // function a dynamic hole in the shell (or produce an empty shell if\n          // there's no parent suspense boundary). Currently, this also includes\n          // layouts and pages that don't read params, which will be improved\n          // when we implement NAR-136. Otherwise, we assume that if params are\n          // passed explicitly into a \"use cache\" function, that the params are\n          // also accessed. This allows us to abort early, and treat the\n          // function as dynamic, instead of waiting for the timeout to be\n          // reached. Compared to the instrumentation-based params bailout we do\n          // here, this also covers the case where params are transformed with\n          // an async function, before being passed into the \"use cache\"\n          // function, which escapes the instrumentation.\n          if (workUnitStore.allowEmptyStaticShell) {\n            return makeHangingPromise(\n              workUnitStore.renderSignal,\n              workStore.route,\n              'dynamic \"use cache\"'\n            )\n          }\n          break\n        case 'prerender-runtime':\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  if (stream === undefined) {\n    const cacheSignal = getCacheSignal(workUnitStore)\n    if (cacheSignal) {\n      // Either the cache handler or the generation can be using I/O at this point.\n      // 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). Redirect\n      // entries have private tags encoding the root param names (one tag per\n      // 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            serializedCacheKey +\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 < DYNAMIC_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          return makeHangingPromise(\n            workUnitStore.renderSignal,\n            workStore.route,\n            'dynamic \"use cache\"'\n          )\n        case 'request': {\n          if (process.env.NODE_ENV === 'development') {\n            // We delay the cache here so that it doesn't resolve in the static task --\n            // in a regular static prerender, it'd be a hanging promise, and we need to reflect that,\n            // so it has to resolve later.\n            // TODO(restart-on-cache-miss): Optimize this to avoid unnecessary restarts.\n            // We don't end the cache read here, so this will always appear as a cache miss in the static stage,\n            // and thus will cause a restart even if all caches are filled.\n            const stagedRendering = workUnitStore.stagedRendering\n            const stage = stagedRendering\n              ? getRuntimeStage(stagedRendering)\n              : RenderStage.Runtime\n            await makeDevtoolsIOAwarePromise(undefined, workUnitStore, stage)\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 (\n      entry === undefined ||\n      currentTime > entry.timestamp + entry.expire * 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 to use the\n      // stale entry since it would unnecessarily need to shorten the lifetime of the\n      // prerender. We're not time constrained here so we can re-generated it now.\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\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      const result = await generateCacheEntry(\n        workStore,\n        cacheContext,\n        clientReferenceManifest,\n        encodedCacheKeyParts,\n        fn,\n        timeoutError\n      )\n\n      if (result.type === 'prerender-dynamic') {\n        return result.hangingPromise\n      }\n\n      const { stream: newStream, pendingCacheResult } = result\n\n      // When draft mode is enabled, we must not save the cache entry.\n      if (!workStore.isDraftMode) {\n        const savedCacheResult = saveToResumeDataCache(\n          prerenderResumeDataCache,\n          serializedCacheKey,\n          pendingCacheResult\n        )\n\n        if (cacheHandler) {\n          saveToCacheHandler(\n            cacheHandler,\n            workStore,\n            id,\n            serializedCacheKey,\n            savedCacheResult,\n            rootParams\n          )\n        }\n      }\n\n      stream = newStream\n    } else {\n      // If we have an entry at this point, this can't be a private cache\n      // entry.\n      if (cacheContext.kind === 'private') {\n        throw new InvariantError(\n          `A private cache entry must not be retrieved from the cache handler.`\n        )\n      }\n\n      maybePropagateCacheEntryMetadata(\n        cacheContext,\n        entry,\n        knownRootParamsByFunctionId.get(id)\n      )\n\n      // We want to return this stream, even if it's stale.\n      stream = entry.value\n\n      // If we have a resume data cache, we need to clone the entry and add it\n      // to the resume data cache.\n      if (prerenderResumeDataCache) {\n        const [entryLeft, entryRight] = cloneCacheEntry(entry)\n        if (cacheSignal) {\n          stream = createTrackedReadableStream(entryLeft.value, cacheSignal)\n        } else {\n          stream = entryLeft.value\n        }\n\n        // The RDC is per-page and root params are fixed within a page, so we\n        // always use the coarse key (without root param suffix).\n        prerenderResumeDataCache.cache.set(\n          serializedCacheKey,\n          Promise.resolve({\n            entry: entryRight,\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            readRootParamNames: knownRootParamNames,\n          })\n        )\n      } else {\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 we do\n        // that inside generateCacheEntry.\n        cacheSignal?.endRead()\n      }\n\n      if (currentTime > entry.timestamp + entry.revalidate * 1000) {\n        // If this is stale, and we're not in a prerender (i.e. this is\n        // dynamic render), then we should warm up the cache with a fresh\n        // revalidated entry.\n        const result = await generateCacheEntry(\n          workStore,\n          // The background revalidation preserves the outer store for reading\n          // (e.g. implicitTags) but skips propagation of cache life and tags\n          // back to the outer scope.\n          {\n            kind: cacheContext.kind,\n            outerWorkUnitStore: cacheContext.outerWorkUnitStore,\n            skipPropagation: true,\n          },\n          clientReferenceManifest,\n          encodedCacheKeyParts,\n          fn,\n          timeoutError\n        )\n\n        if (result.type === 'cached') {\n          const { stream: ignoredStream, pendingCacheResult } = result\n\n          const savedCacheResult = saveToResumeDataCache(\n            prerenderResumeDataCache,\n            serializedCacheKey,\n            pendingCacheResult\n          )\n\n          if (cacheHandler) {\n            saveToCacheHandler(\n              cacheHandler,\n              workStore,\n              id,\n              serializedCacheKey,\n              savedCacheResult,\n              rootParams\n            )\n          }\n\n          await ignoredStream.cancel()\n        }\n      }\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: CacheEntry,\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 (entry.tags.some((tag) => isRecentlyRevalidatedTag(tag, workStore))) {\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 (implicitTags.some((tag) => isRecentlyRevalidatedTag(tag, workStore))) {\n    return true\n  }\n\n  return false\n}\n\nfunction isRecentlyRevalidatedTag(tag: string, workStore: WorkStore): boolean {\n  const { previouslyRevalidatedTags, pendingRevalidatedTags } = workStore\n\n  // Was the tag previously revalidated (e.g. by a redirecting server action)?\n  if (previouslyRevalidatedTags.includes(tag)) {\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 (pendingRevalidatedTags?.some((item) => item.tag === tag)) {\n    debug?.('tag', tag, 'was just revalidated')\n\n    return true\n  }\n\n  return false\n}\n"],"names":["cache","isEdgeRuntime","process","env","NEXT_RUNTIME","debug","NEXT_PRIVATE_DEBUG_CACHE","console","bind","undefined","filterStackFrame","NODE_ENV","require","filterStackFrameDEV","findSourceMapURL","findSourceMapURLDEV","nestedCacheZeroRevalidateErrorMessage","nestedCacheShortExpireErrorMessage","knownRootParamsByFunctionId","Map","addKnownRootParamNames","id","names","existing","get","name","add","created","Set","set","computeRootParamsCacheKeySuffix","rootParams","paramNames","size","JSON","stringify","sort","map","paramName","saveToResumeDataCache","prerenderResumeDataCache","serializedCacheKey","pendingCacheResult","split","clonePendingCacheResult","savedCacheResult","getNthCacheResult","rdcResult","saveToCacheHandler","cacheHandler","workStore","pendingCoarseEntry","then","collectedResult","entry","fullEntry","readRootParamNames","rootParamNames","specificKey","specificSetPromise","Promise","resolve","pendingRevalidateWrites","push","rootParamTags","NEXT_CACHE_ROOT_PARAM_TAG_ID","value","ReadableStream","start","controller","enqueue","Uint8Array","close","tags","stale","timestamp","expire","revalidate","promise","generateCacheEntry","cacheContext","clientReferenceManifest","encodedArguments","fn","timeoutError","runInCleanSnapshot","generateCacheEntryWithRestoredWorkStore","workAsyncStorage","run","generateCacheEntryWithCacheContext","createUseCacheStore","defaultCacheLife","kind","outerWorkUnitStore","type","phase","implicitTags","explicitRevalidate","explicitExpire","explicitStale","hmrRefreshHash","getHmrRefreshHash","isHmrRefresh","serverComponentsHmrCache","getServerComponentsHmrCache","forceRevalidate","shouldForceRevalidate","draftMode","getDraftModeProviderForCacheScope","headers","cookies","useCacheOrRequestStore","assertDefaultCacheLife","InvariantError","cacheLifeProfiles","cacheStore","workUnitAsyncStorage","dynamicAccessAsyncStorage","abortController","AbortController","generateCacheEntryImpl","propagateCacheLifeAndTagsToRevalidateStore","revalidateStore","outerTags","tag","includes","propagateCacheStaleTimeToRequestStore","requestStore","propagateCacheEntryMetadata","maybePropagateCacheEntryMetadata","cacheSignal","collectResult","savedStream","innerCacheStore","startTime","errors","buffer","reader","getReader","read","done","error","idx","bufferStream","pull","invalidDynamicUsageError","length","collectedTags","collectedRevalidate","collectedExpire","collectedStale","skipPropagation","getCacheSignal","endRead","hasExplicitRevalidate","hasExplicitExpire","temporaryReferences","createServerTemporaryReferenceSet","args","decodeReply","getServerModuleMap","decodeReplyFromAsyncIterable","Symbol","asyncIterator","renderSignal","aborted","addEventListener","once","performance","timeOrigin","now","resultPromise","createLazyResult","handleError","createReactServerErrorHandler","isBuildTimePrerendering","reactServerErrorsByDigest","Log","stream","timeoutAbortController","timer","setTimeout","abort","dynamicAccessAbortSignal","getStore","signal","abortSignal","AbortSignal","any","prelude","prerender","clientModules","environmentName","onError","reason","clearTimeout","hangingPromise","makeHangingPromise","route","renderToReadableStream","returnStream","tee","cloneCacheEntry","streamA","streamB","clonedEntry","cloneCacheResult","result","entryA","entryB","i","encodeFormData","formData","key","toString","stringValue","arrayBuffer","byteLength","String","fromCodePoint","Uint16Array","createTrackedReadableStream","boundArgsLength","originalFn","workUnitStore","isPrivate","getCacheHandler","Error","UseCacheTimeoutError","captureStackTrace","wrapAsInvalidDynamicUsageError","expression","postponeWithTracking","dynamicTracking","throwToInterruptStaticGeneration","getClientReferenceManifest","buildId","hangingInputAbortSignal","createHangingInputAbortSignal","stagedRendering","waitForStage","getRuntimeStage","stage","RenderStage","Runtime","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","knownRootParamNames","cacheHandlerKey","getPrerenderResumeDataCache","renderResumeDataCache","getRenderResumeDataCache","beginRead","rdcEntry","some","isRecentlyRevalidatedTag","DYNAMIC_EXPIRE","RUNTIME_PREFETCH_DYNAMIC_STALE","Dynamic","allowEmptyStaticShell","lazyRefreshTags","refreshTagsByCacheKind","isResolvedLazyResult","startsWith","slice","implicitTagsExpiration","lazyExpiration","expirationsByCacheKind","expiration","Infinity","shouldDiscardCacheEntry","currentTime","isStaticGeneration","newStream","isDraftMode","entryLeft","entryRight","ignoredStream","cancel","replayConsoleLogs","serverConsumerManifest","moduleLoading","moduleMap","edgeRscModuleMapping","rscModuleMapping","serverModuleMap","createFromReadableStream","maybeProps","$$isPage","isOnDemandRevalidate","__NEXT_DEV_SERVER","previouslyRevalidatedTags","pendingRevalidatedTags","item"],"mappings":";;;;+B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