{"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.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 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":["renderToReadableStream","decodeReply","decodeReplyFromAsyncIterable","createTemporaryReferenceSet","createServerTemporaryReferenceSet","createFromReadableStream","encodeReply","createClientTemporaryReferenceSet","prerender","workAsyncStorage","getHmrRefreshHash","getRenderResumeDataCache","getPrerenderResumeDataCache","workUnitAsyncStorage","getDraftModeProviderForCacheScope","getCacheSignal","isHmrRefresh","getServerComponentsHmrCache","getRuntimeStage","makeDevtoolsIOAwarePromise","makeHangingPromise","getClientReferenceManifest","getServerModuleMap","decryptActionBoundArgs","InvariantError","createReactServerErrorHandler","DYNAMIC_EXPIRE","RUNTIME_PREFETCH_DYNAMIC_STALE","NEXT_CACHE_ROOT_PARAM_TAG_ID","getCacheHandler","UseCacheTimeoutError","createHangingInputAbortSignal","postponeWithTracking","throwToInterruptStaticGeneration","makeErroringSearchParamsForUseCache","createLazyResult","isResolvedLazyResult","dynamicAccessAsyncStorage","RenderStage","Log","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","cache","saveToCacheHandler","cacheHandler","workStore","pendingCoarseEntry","then","collectedResult","entry","fullEntry","readRootParamNames","rootParamNames","specificKey","specificSetPromise","Promise","resolve","pendingRevalidateWrites","push","rootParamTags","value","ReadableStream","start","controller","enqueue","Uint8Array","close","tags","stale","timestamp","expire","revalidate","promise","generateCacheEntry","cacheContext","clientReferenceManifest","encodedArguments","fn","timeoutError","runInCleanSnapshot","generateCacheEntryWithRestoredWorkStore","run","generateCacheEntryWithCacheContext","createUseCacheStore","defaultCacheLife","kind","outerWorkUnitStore","type","phase","implicitTags","explicitRevalidate","explicitExpire","explicitStale","hmrRefreshHash","serverComponentsHmrCache","forceRevalidate","shouldForceRevalidate","draftMode","headers","cookies","useCacheOrRequestStore","assertDefaultCacheLife","cacheLifeProfiles","cacheStore","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","endRead","hasExplicitRevalidate","hasExplicitExpire","temporaryReferences","args","Symbol","asyncIterator","renderSignal","aborted","addEventListener","once","performance","timeOrigin","now","resultPromise","handleError","isBuildTimePrerendering","reactServerErrorsByDigest","stream","timeoutAbortController","timer","setTimeout","abort","dynamicAccessAbortSignal","getStore","signal","abortSignal","AbortSignal","any","prelude","clientModules","environmentName","onError","reason","clearTimeout","hangingPromise","route","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","Error","captureStackTrace","wrapAsInvalidDynamicUsageError","expression","dynamicTracking","buildId","deploymentId","hangingInputAbortSignal","stagedRendering","waitForStage","stage","Runtime","isPageOrLayoutSegmentFunction","isPageSegmentFunction","params","outerParams","searchParams","outerSearchParams","otherOuterArgs","props","_innerParams","innerSearchParams","otherInnerArgs","apply","isLayoutSegmentFunction","$$isLayout","outerSlots","innerSlots","encryptedBoundArgs","shift","boundArgs","Array","isArray","unshift","cacheKeyParts","encodeCacheKeyParts","encodedCacheKeyParts","dynamicAccessAbortController","knownRootParamNames","cacheHandlerKey","renderResumeDataCache","beginRead","rdcEntry","some","isRecentlyRevalidatedTag","Dynamic","allowEmptyStaticShell","lazyRefreshTags","refreshTagsByCacheKind","startsWith","slice","implicitTagsExpiration","lazyExpiration","expirationsByCacheKind","expiration","Infinity","shouldDiscardCacheEntry","currentTime","isStaticGeneration","newStream","isDraftMode","entryLeft","entryRight","ignoredStream","cancel","replayConsoleLogs","serverConsumerManifest","moduleLoading","moduleMap","edgeRscModuleMapping","rscModuleMapping","serverModuleMap","maybeProps","$$isPage","isOnDemandRevalidate","__NEXT_DEV_SERVER","previouslyRevalidat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