next 15.0.4-canary.2 → 15.0.4-canary.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of next might be problematic. Click here for more details.

Files changed (51) hide show
  1. package/dist/bin/next +1 -1
  2. package/dist/build/index.js +2 -2
  3. package/dist/build/swc/index.js +1 -1
  4. package/dist/build/webpack-config.js +2 -2
  5. package/dist/client/app-bootstrap.js +1 -1
  6. package/dist/client/index.js +1 -1
  7. package/dist/compiled/@edge-runtime/primitives/abort-controller.js.text.js +1 -1
  8. package/dist/compiled/@edge-runtime/primitives/blob.js.text.js +1 -1
  9. package/dist/compiled/@edge-runtime/primitives/console.js.text.js +1 -1
  10. package/dist/compiled/@edge-runtime/primitives/crypto.js.text.js +1 -1
  11. package/dist/compiled/@edge-runtime/primitives/events.js.text.js +1 -1
  12. package/dist/compiled/@edge-runtime/primitives/fetch.js.text.js +1 -1
  13. package/dist/compiled/@edge-runtime/primitives/package.json +1 -1
  14. package/dist/compiled/@edge-runtime/primitives/structured-clone.js.text.js +1 -1
  15. package/dist/compiled/@edge-runtime/primitives/timers.js.text.js +1 -1
  16. package/dist/compiled/@edge-runtime/primitives/url.js.text.js +1 -1
  17. package/dist/compiled/babel/bundle.js +11 -11
  18. package/dist/compiled/babel-packages/packages-bundle.js +3 -3
  19. package/dist/compiled/edge-runtime/index.js +1 -1
  20. package/dist/compiled/next-server/server.runtime.prod.js +10 -10
  21. package/dist/compiled/next-server/server.runtime.prod.js.map +1 -1
  22. package/dist/esm/build/index.js +2 -2
  23. package/dist/esm/build/swc/index.js +1 -1
  24. package/dist/esm/build/webpack-config.js +2 -2
  25. package/dist/esm/client/app-bootstrap.js +1 -1
  26. package/dist/esm/client/index.js +1 -1
  27. package/dist/esm/server/app-render/encryption.js +2 -1
  28. package/dist/esm/server/app-render/encryption.js.map +1 -1
  29. package/dist/esm/server/config.js +1 -1
  30. package/dist/esm/server/dev/hot-reloader-turbopack.js +1 -1
  31. package/dist/esm/server/dev/hot-reloader-webpack.js +1 -1
  32. package/dist/esm/server/lib/app-info-log.js +1 -1
  33. package/dist/esm/server/lib/start-server.js +1 -1
  34. package/dist/esm/server/use-cache/use-cache-wrapper.js +17 -1
  35. package/dist/esm/server/use-cache/use-cache-wrapper.js.map +1 -1
  36. package/dist/server/app-render/encryption.js +2 -1
  37. package/dist/server/app-render/encryption.js.map +1 -1
  38. package/dist/server/config.js +1 -1
  39. package/dist/server/dev/hot-reloader-turbopack.js +1 -1
  40. package/dist/server/dev/hot-reloader-webpack.js +1 -1
  41. package/dist/server/lib/app-info-log.js +1 -1
  42. package/dist/server/lib/start-server.js +1 -1
  43. package/dist/server/use-cache/use-cache-wrapper.d.ts +1 -1
  44. package/dist/server/use-cache/use-cache-wrapper.js +17 -1
  45. package/dist/server/use-cache/use-cache-wrapper.js.map +1 -1
  46. package/dist/telemetry/anonymous-meta.js +1 -1
  47. package/dist/telemetry/events/session-stopped.js +2 -2
  48. package/dist/telemetry/events/version.js +2 -2
  49. package/experimental/testing/server.d.ts +1 -1
  50. package/experimental/testing/server.js +1 -1
  51. package/package.json +17 -17
@@ -1 +1 @@
1
- {"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 createTemporaryReferenceSet as createServerTemporaryReferenceSet,\n} from 'react-server-dom-webpack/server.edge'\n/* eslint-disable import/no-extraneous-dependencies */\nimport {\n createFromReadableStream,\n encodeReply,\n createTemporaryReferenceSet as createClientTemporaryReferenceSet,\n} from 'react-server-dom-webpack/client.edge'\n\nimport type { WorkStore } from '../app-render/work-async-storage.external'\nimport { workAsyncStorage } from '../app-render/work-async-storage.external'\nimport type {\n UseCacheStore,\n WorkUnitStore,\n} from '../app-render/work-unit-async-storage.external'\nimport {\n getRenderResumeDataCache,\n getPrerenderResumeDataCache,\n workUnitAsyncStorage,\n} from '../app-render/work-unit-async-storage.external'\nimport { runInCleanSnapshot } from '../app-render/clean-async-snapshot.external'\n\nimport { makeHangingPromise } from '../dynamic-rendering-utils'\n\nimport type { ClientReferenceManifestForRsc } from '../../build/webpack/plugins/flight-manifest-plugin'\n\nimport {\n getClientReferenceManifestForRsc,\n getServerModuleMap,\n} from '../app-render/encryption-utils'\nimport DefaultCacheHandler from '../lib/cache-handlers/default'\nimport type { CacheHandler, CacheEntry } from '../lib/cache-handlers/types'\nimport type { CacheSignal } from '../app-render/cache-signal'\n\nconst isEdgeRuntime = process.env.NEXT_RUNTIME === 'edge'\n\n// If the expire time is less than .\nconst DYNAMIC_EXPIRE = 300\n\nconst cacheHandlersSymbol = Symbol.for('@next/cache-handlers')\nconst _globalThis: typeof globalThis & {\n [cacheHandlersSymbol]?: {\n RemoteCache?: CacheHandler\n DefaultCache?: CacheHandler\n }\n __nextCacheHandlers?: Record<string, CacheHandler>\n} = globalThis\n\nconst cacheHandlerMap: Map<string, CacheHandler> = new Map([\n [\n 'default',\n _globalThis[cacheHandlersSymbol]?.DefaultCache || DefaultCacheHandler,\n ],\n [\n 'remote',\n // in dev remote maps to default handler\n // and is meant to be overridden in prod\n _globalThis[cacheHandlersSymbol]?.RemoteCache || DefaultCacheHandler,\n ],\n])\n\nfunction generateCacheEntry(\n workStore: WorkStore,\n outerWorkUnitStore: WorkUnitStore | undefined,\n clientReferenceManifest: DeepReadonly<ClientReferenceManifestForRsc>,\n encodedArguments: FormData | string,\n fn: any\n): Promise<[ReadableStream, Promise<CacheEntry>]> {\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 runInCleanSnapshot(\n generateCacheEntryWithRestoredWorkStore,\n workStore,\n outerWorkUnitStore,\n clientReferenceManifest,\n encodedArguments,\n fn\n )\n}\n\nfunction generateCacheEntryWithRestoredWorkStore(\n workStore: WorkStore,\n outerWorkUnitStore: WorkUnitStore | undefined,\n clientReferenceManifest: DeepReadonly<ClientReferenceManifestForRsc>,\n encodedArguments: FormData | string,\n fn: any\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 outerWorkUnitStore,\n clientReferenceManifest,\n encodedArguments,\n fn\n )\n}\n\nfunction generateCacheEntryWithCacheContext(\n workStore: WorkStore,\n outerWorkUnitStore: WorkUnitStore | undefined,\n clientReferenceManifest: DeepReadonly<ClientReferenceManifestForRsc>,\n encodedArguments: FormData | string,\n fn: any\n) {\n if (!workStore.cacheLifeProfiles) {\n throw new Error(\n 'cacheLifeProfiles should always be provided. This is a bug in Next.js.'\n )\n }\n const defaultCacheLife = workStore.cacheLifeProfiles['default']\n if (\n !defaultCacheLife ||\n defaultCacheLife.revalidate == null ||\n defaultCacheLife.expire == null ||\n defaultCacheLife.stale == null\n ) {\n throw new Error(\n 'A default cacheLife profile must always be provided. This is a bug in Next.js.'\n )\n }\n\n // Initialize the Store for this Cache entry.\n const cacheStore: UseCacheStore = {\n type: 'cache',\n phase: 'render',\n implicitTags:\n outerWorkUnitStore === undefined ||\n outerWorkUnitStore.type === 'unstable-cache'\n ? []\n : 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 }\n return workUnitAsyncStorage.run(\n cacheStore,\n generateCacheEntryImpl,\n workStore,\n outerWorkUnitStore,\n cacheStore,\n clientReferenceManifest,\n encodedArguments,\n fn\n )\n}\n\nfunction propagateCacheLifeAndTags(\n workUnitStore: WorkUnitStore | undefined,\n entry: CacheEntry\n): void {\n if (\n workUnitStore &&\n (workUnitStore.type === 'cache' ||\n workUnitStore.type === 'prerender' ||\n workUnitStore.type === 'prerender-ppr' ||\n workUnitStore.type === 'prerender-legacy')\n ) {\n // Propagate tags and revalidate upwards\n const outerTags = workUnitStore.tags ?? (workUnitStore.tags = [])\n const entryTags = entry.tags\n for (let i = 0; i < entryTags.length; i++) {\n const tag = entryTags[i]\n if (!outerTags.includes(tag)) {\n outerTags.push(tag)\n }\n }\n if (workUnitStore.stale > entry.stale) {\n workUnitStore.stale = entry.stale\n }\n if (workUnitStore.revalidate > entry.revalidate) {\n workUnitStore.revalidate = entry.revalidate\n }\n if (workUnitStore.expire > entry.expire) {\n workUnitStore.expire = entry.expire\n }\n }\n}\n\nasync function collectResult(\n savedStream: ReadableStream,\n outerWorkUnitStore: WorkUnitStore | undefined,\n innerCacheStore: UseCacheStore,\n startTime: number,\n errors: Array<unknown>, // This is a live array that gets pushed into.,\n timer: any\n): Promise<CacheEntry> {\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: any[] = []\n const reader = savedStream.getReader()\n for (let entry; !(entry = await reader.read()).done; ) {\n buffer.push(entry.value)\n }\n\n let idx = 0\n const bufferStream = new ReadableStream({\n pull(controller) {\n 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 = {\n value: bufferStream,\n timestamp: startTime,\n revalidate: collectedRevalidate,\n expire: collectedExpire,\n stale: collectedStale,\n tags: collectedTags === null ? [] : collectedTags,\n }\n // Propagate tags/revalidate to the parent context.\n propagateCacheLifeAndTags(outerWorkUnitStore, entry)\n\n const cacheSignal =\n outerWorkUnitStore && outerWorkUnitStore.type === 'prerender'\n ? outerWorkUnitStore.cacheSignal\n : null\n if (cacheSignal) {\n cacheSignal.endRead()\n }\n\n if (timer !== undefined) {\n clearTimeout(timer)\n }\n\n return entry\n}\n\nasync function generateCacheEntryImpl(\n workStore: WorkStore,\n outerWorkUnitStore: WorkUnitStore | undefined,\n innerCacheStore: UseCacheStore,\n clientReferenceManifest: DeepReadonly<ClientReferenceManifestForRsc>,\n encodedArguments: FormData | string,\n fn: any\n): Promise<[ReadableStream, Promise<CacheEntry>]> {\n const temporaryReferences = createServerTemporaryReferenceSet()\n\n const [, , args] = await decodeReply<any[]>(\n encodedArguments,\n getServerModuleMap(),\n {\n temporaryReferences,\n }\n )\n\n // Track the timestamp when we started copmuting the result.\n const startTime = performance.timeOrigin + performance.now()\n // Invoke the inner function to load a new result.\n const result = fn.apply(null, args)\n\n let errors: Array<unknown> = []\n\n let timer = undefined\n const controller = new AbortController()\n if (workStore.isStaticGeneration) {\n // If we're prerendering, we give you 50 seconds to fill a cache entry. Otherwise\n // we assume you stalled on hanging input and deopt. This needs to be lower than\n // just the general timeout of 60 seconds.\n timer = setTimeout(() => {\n controller.abort(\n new Error(\n 'Filling a cache during prerender timed out, likely because request-specific arguments such as ' +\n 'params, searchParams, cookies() or dynamic data were used inside \"use cache\".'\n )\n )\n }, 50000)\n }\n\n const stream = renderToReadableStream(\n result,\n clientReferenceManifest.clientModules,\n {\n environmentName: 'Cache',\n signal: controller.signal,\n temporaryReferences,\n onError(error: unknown) {\n // Report the error.\n console.error(error)\n errors.push(error)\n },\n }\n )\n\n const [returnStream, savedStream] = stream.tee()\n\n const promiseOfCacheEntry = collectResult(\n savedStream,\n outerWorkUnitStore,\n innerCacheStore,\n startTime,\n errors,\n timer\n )\n\n // Return the stream as we're creating it. This means that if it ends up\n // erroring we cannot return a stale-while-error version but it allows\n // streaming back the result earlier.\n return [returnStream, promiseOfCacheEntry]\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\nasync function clonePendingCacheEntry(\n pendingCacheEntry: Promise<CacheEntry>\n): Promise<[CacheEntry, CacheEntry]> {\n const entry = await pendingCacheEntry\n return cloneCacheEntry(entry)\n}\n\nasync function getNthCacheEntry(\n split: Promise<[CacheEntry, CacheEntry]>,\n i: number\n): Promise<CacheEntry> {\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 function cache(kind: string, id: string, fn: any) {\n if (!process.env.__NEXT_DYNAMIC_IO) {\n throw new Error(\n '\"use cache\" is only available with the experimental.dynamicIO config.'\n )\n }\n for (const [key, value] of Object.entries(\n _globalThis.__nextCacheHandlers || {}\n )) {\n cacheHandlerMap.set(key, value as CacheHandler)\n }\n const cacheHandler = cacheHandlerMap.get(kind)\n\n if (cacheHandler === undefined) {\n throw new Error('Unknown cache handler: ' + kind)\n }\n const name = fn.name\n const cachedFn = {\n [name]: async function (...args: any[]) {\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\n // Get the clientReferenceManifest while we're still in the outer Context.\n // In case getClientReferenceManifestSingleton is implemented using AsyncLocalStorage.\n const clientReferenceManifest = getClientReferenceManifestForRsc()\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 let abortHangingInputSignal: null | AbortSignal = null\n if (workUnitStore && workUnitStore.type === 'prerender') {\n // In a prerender, we may end up with hanging Promises as inputs due them stalling\n // on connection() or because they're loading dynamic data. In that case we need to\n // abort the encoding of the arguments since they'll never complete.\n const controller = new AbortController()\n abortHangingInputSignal = controller.signal\n if (workUnitStore.cacheSignal) {\n // If we have a cacheSignal it means we're in a prospective render. If the input\n // we're waiting on is coming from another cache, we do want to wait for it so that\n // we can resolve this cache entry too.\n workUnitStore.cacheSignal.inputReady().then(() => {\n controller.abort()\n })\n } else {\n // Otherwise we're in the final render and we should already have all our caches\n // filled. We might still be waiting on some microtasks so we wait one tick before\n // giving up. When we give up, we still want to render the content of this cache\n // as deeply as we can so that we can suspend as deeply as possible in the tree\n // or not at all if we don't end up waiting for the input.\n process.nextTick(() => controller.abort())\n }\n }\n\n const temporaryReferences = createClientTemporaryReferenceSet()\n const encodedArguments: FormData | string = await encodeReply(\n [buildId, id, args],\n // Right now this is enough to cause the input to generate hanging Promises\n // but that's really due to what is probably a React bug in decodeReply.\n // If that's fixed we may need a different strategy. We can also just skip\n // the serialization/cache in this scenario and pass-through raw objects.\n abortHangingInputSignal\n ? {\n temporaryReferences,\n signal: abortHangingInputSignal,\n }\n : {\n temporaryReferences,\n }\n )\n\n const serializedCacheKey =\n typeof encodedArguments === '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 encodedArguments\n : await encodeFormData(encodedArguments)\n\n let stream: undefined | ReadableStream = undefined\n\n // Get an immutable and mutable versions of the resume data cache.\n const prerenderResumeDataCache = workUnitStore\n ? getPrerenderResumeDataCache(workUnitStore)\n : null\n const renderResumeDataCache = workUnitStore\n ? getRenderResumeDataCache(workUnitStore)\n : null\n\n if (renderResumeDataCache) {\n const cacheSignal =\n workUnitStore && workUnitStore.type === 'prerender'\n ? workUnitStore.cacheSignal\n : null\n\n if (cacheSignal) {\n cacheSignal.beginRead()\n }\n const cachedEntry = renderResumeDataCache.cache.get(serializedCacheKey)\n if (cachedEntry !== undefined) {\n const existingEntry = await cachedEntry\n propagateCacheLifeAndTags(workUnitStore, existingEntry)\n if (\n workUnitStore !== undefined &&\n workUnitStore.type === 'prerender' &&\n existingEntry !== undefined &&\n (existingEntry.revalidate === 0 ||\n existingEntry.expire < DYNAMIC_EXPIRE)\n ) {\n // In a Dynamic I/O prerender, if the cache entry has revalidate: 0 or if the\n // expire time is under 5 minutes, then we consider this cache entry dynamic\n // as it's not worth generating static pages for such data. It's better to leave\n // a PPR hole that can be filled in dynamically with a potentially cached entry.\n if (cacheSignal) {\n cacheSignal.endRead()\n }\n return makeHangingPromise(\n workUnitStore.renderSignal,\n 'dynamic \"use cache\"'\n )\n }\n const [streamA, streamB] = existingEntry.value.tee()\n existingEntry.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 if (cacheSignal) {\n cacheSignal.endRead()\n }\n }\n }\n\n if (stream === undefined) {\n const cacheSignal =\n workUnitStore && workUnitStore.type === 'prerender'\n ? workUnitStore.cacheSignal\n : null\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 implicitTags =\n workUnitStore === undefined || workUnitStore.type === 'unstable-cache'\n ? []\n : workUnitStore.implicitTags\n const entry: undefined | CacheEntry = await cacheHandler.get(\n serializedCacheKey,\n implicitTags\n )\n const currentTime = performance.timeOrigin + performance.now()\n if (\n workUnitStore !== undefined &&\n workUnitStore.type === 'prerender' &&\n entry !== undefined &&\n (entry.revalidate === 0 || entry.expire < DYNAMIC_EXPIRE)\n ) {\n // In a Dynamic I/O prerender, if the cache entry has revalidate: 0 or if the\n // expire time is under 5 minutes, then we consider this cache entry dynamic\n // as it's not worth generating static pages for such data. It's better to leave\n // a PPR hole that can be filled in dynamically with a potentially cached entry.\n if (cacheSignal) {\n cacheSignal.endRead()\n }\n\n return makeHangingPromise(\n workUnitStore.renderSignal,\n 'dynamic \"use cache\"'\n )\n } else 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 const [newStream, pendingCacheEntry] = await generateCacheEntry(\n workStore,\n workUnitStore,\n clientReferenceManifest,\n encodedArguments,\n fn\n )\n\n let savedCacheEntry\n if (prerenderResumeDataCache) {\n // Create a clone that goes into the cache scope memory cache.\n const split = clonePendingCacheEntry(pendingCacheEntry)\n savedCacheEntry = getNthCacheEntry(split, 0)\n prerenderResumeDataCache.cache.set(\n serializedCacheKey,\n getNthCacheEntry(split, 1)\n )\n } else {\n savedCacheEntry = pendingCacheEntry\n }\n\n const promise = cacheHandler.set(serializedCacheKey, savedCacheEntry)\n\n if (!workStore.pendingRevalidateWrites) {\n workStore.pendingRevalidateWrites = []\n }\n workStore.pendingRevalidateWrites.push(promise)\n\n stream = newStream\n } else {\n propagateCacheLifeAndTags(workUnitStore, entry)\n\n // We want to return this stream, even if it's stale.\n stream = entry.value\n\n // If we have a cache scope, we need to clone the entry and set it on\n // the inner cache scope.\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 prerenderResumeDataCache.cache.set(\n serializedCacheKey,\n Promise.resolve(entryRight)\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 dynamic render),\n // then we should warm up the cache with a fresh revalidated entry.\n const [ignoredStream, pendingCacheEntry] = await generateCacheEntry(\n workStore,\n undefined, // This is not running within the context of this unit.\n clientReferenceManifest,\n encodedArguments,\n fn\n )\n\n let savedCacheEntry: Promise<CacheEntry>\n if (prerenderResumeDataCache) {\n const split = clonePendingCacheEntry(pendingCacheEntry)\n savedCacheEntry = getNthCacheEntry(split, 0)\n prerenderResumeDataCache.cache.set(\n serializedCacheKey,\n getNthCacheEntry(split, 1)\n )\n } else {\n savedCacheEntry = pendingCacheEntry\n }\n\n const promise = cacheHandler.set(\n serializedCacheKey,\n savedCacheEntry\n )\n\n if (!workStore.pendingRevalidateWrites) {\n workStore.pendingRevalidateWrites = []\n }\n workStore.pendingRevalidateWrites.push(promise)\n\n await ignoredStream.cancel()\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 serverConsumerManifest,\n temporaryReferences,\n replayConsoleLogs,\n environmentName: 'Cache',\n })\n },\n }[name]\n return cachedFn\n}\n"],"names":["cache","_globalThis","isEdgeRuntime","process","env","NEXT_RUNTIME","DYNAMIC_EXPIRE","cacheHandlersSymbol","Symbol","for","globalThis","cacheHandlerMap","Map","DefaultCache","DefaultCacheHandler","RemoteCache","generateCacheEntry","workStore","outerWorkUnitStore","clientReferenceManifest","encodedArguments","fn","runInCleanSnapshot","generateCacheEntryWithRestoredWorkStore","workAsyncStorage","run","generateCacheEntryWithCacheContext","cacheLifeProfiles","Error","defaultCacheLife","revalidate","expire","stale","cacheStore","type","phase","implicitTags","undefined","explicitRevalidate","explicitExpire","explicitStale","tags","workUnitAsyncStorage","generateCacheEntryImpl","propagateCacheLifeAndTags","workUnitStore","entry","outerTags","entryTags","i","length","tag","includes","push","collectResult","savedStream","innerCacheStore","startTime","errors","timer","buffer","reader","getReader","read","done","value","idx","bufferStream","ReadableStream","pull","controller","enqueue","error","close","collectedTags","collectedRevalidate","collectedExpire","collectedStale","timestamp","cacheSignal","endRead","clearTimeout","temporaryReferences","createServerTemporaryReferenceSet","args","decodeReply","getServerModuleMap","performance","timeOrigin","now","result","apply","AbortController","isStaticGeneration","setTimeout","abort","stream","renderToReadableStream","clientModules","environmentName","signal","onError","console","returnStream","tee","promiseOfCacheEntry","cloneCacheEntry","streamA","streamB","clonedEntry","clonePendingCacheEntry","pendingCacheEntry","getNthCacheEntry","split","encodeFormData","formData","key","toString","stringValue","arrayBuffer","byteLength","String","fromCodePoint","Uint16Array","Uint8Array","createTrackedReadableStream","kind","id","__NEXT_DYNAMIC_IO","Object","entries","__nextCacheHandlers","set","cacheHandler","get","name","cachedFn","getStore","getClientReferenceManifestForRsc","buildId","abortHangingInputSignal","inputReady","then","nextTick","createClientTemporaryReferenceSet","encodeReply","serializedCacheKey","prerenderResumeDataCache","getPrerenderResumeDataCache","renderResumeDataCache","getRenderResumeDataCache","beginRead","cachedEntry","existingEntry","makeHangingPromise","renderSignal","currentTime","newStream","savedCacheEntry","promise","pendingRevalidateWrites","entryLeft","entryRight","Promise","resolve","ignoredStream","cancel","replayConsoleLogs","serverConsumerManifest","moduleLoading","moduleMap","edgeRscModuleMapping","rscModuleMapping","serverModuleMap","createFromReadableStream"],"mappings":";;;;+BAmbgBA;;;eAAAA;;;4BA7aT;4BAMA;0CAG0B;8CAS1B;4CAC4B;uCAEA;iCAO5B;gEACyB;;;;;;IAqB5BC,iCAIA,wCAAwC;AACxC,wCAAwC;AACxCA;AAvBJ,MAAMC,gBAAgBC,QAAQC,GAAG,CAACC,YAAY,KAAK;AAEnD,oCAAoC;AACpC,MAAMC,iBAAiB;AAEvB,MAAMC,sBAAsBC,OAAOC,GAAG,CAAC;AACvC,MAAMR,cAMFS;AAEJ,MAAMC,kBAA6C,IAAIC,IAAI;IACzD;QACE;QACAX,EAAAA,kCAAAA,WAAW,CAACM,oBAAoB,qBAAhCN,gCAAkCY,YAAY,KAAIC,gBAAmB;KACtE;IACD;QACE;QAGAb,EAAAA,mCAAAA,WAAW,CAACM,oBAAoB,qBAAhCN,iCAAkCc,WAAW,KAAID,gBAAmB;KACrE;CACF;AAED,SAASE,mBACPC,SAAoB,EACpBC,kBAA6C,EAC7CC,uBAAoE,EACpEC,gBAAmC,EACnCC,EAAO;IAEP,kFAAkF;IAClF,mFAAmF;IACnF,+EAA+E;IAC/E,mFAAmF;IACnF,6EAA6E;IAC7E,OAAOC,IAAAA,8CAAkB,EACvBC,yCACAN,WACAC,oBACAC,yBACAC,kBACAC;AAEJ;AAEA,SAASE,wCACPN,SAAoB,EACpBC,kBAA6C,EAC7CC,uBAAoE,EACpEC,gBAAmC,EACnCC,EAAO;IAEP,2EAA2E;IAC3E,6EAA6E;IAC7E,sFAAsF;IACtF,sFAAsF;IACtF,+EAA+E;IAC/E,sFAAsF;IACtF,0DAA0D;IAC1D,OAAOG,0CAAgB,CAACC,GAAG,CACzBR,WACAS,oCACAT,WACAC,oBACAC,yBACAC,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C,kBAAkB9C,iBAAiBC,OAAO;4BAC1CkC,yBAAyBnJ,KAAK,CAACoI,GAAG,CAChCc,oBACAlC,iBAAiBC,OAAO;wBAE5B,OAAO;4BACL6C,kBAAkB/C;wBACpB;wBAEA,MAAMgD,UAAU1B,aAAaD,GAAG,CAC9Bc,oBACAY;wBAGF,IAAI,CAAC7I,UAAU+I,uBAAuB,EAAE;4BACtC/I,UAAU+I,uBAAuB,GAAG,EAAE;wBACxC;wBACA/I,UAAU+I,uBAAuB,CAAC3G,IAAI,CAAC0G;wBAEvC,MAAMM,cAAcC,MAAM;oBAC5B;gBACF;YACF;YAEA,yFAAyF;YACzF,0FAA0F;YAC1F,wFAAwF;YACxF,uFAAuF;YACvF,qFAAqF;YACrF,uFAAuF;YACvF,iFAAiF;YACjF,MAAMC,oBAAoB;YAE1B,MAAMC,yBAAyB;gBAC7B,2FAA2F;gBAC3F,yFAAyF;gBACzF,+CAA+C;gBAC/CC,eAAe;gBACfC,WAAWxK,gBACPiB,wBAAwBwJ,oBAAoB,GAC5CxJ,wBAAwByJ,gBAAgB;gBAC5CC,iBAAiBvF,IAAAA,mCAAkB;YACrC;YAEA,OAAOwF,IAAAA,oCAAwB,EAAC9E,QAAQ;gBACtCwE;gBACAtF;gBACAqF;gBACApE,iBAAiB;YACnB;QACF;IACF,CAAC,CAACoC,KAAK;IACP,OAAOC;AACT"}
1
+ {"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 createTemporaryReferenceSet as createServerTemporaryReferenceSet,\n} from 'react-server-dom-webpack/server.edge'\n/* eslint-disable import/no-extraneous-dependencies */\nimport {\n createFromReadableStream,\n encodeReply,\n createTemporaryReferenceSet as createClientTemporaryReferenceSet,\n} from 'react-server-dom-webpack/client.edge'\n\nimport type { WorkStore } from '../app-render/work-async-storage.external'\nimport { workAsyncStorage } from '../app-render/work-async-storage.external'\nimport type {\n UseCacheStore,\n WorkUnitStore,\n} from '../app-render/work-unit-async-storage.external'\nimport {\n getRenderResumeDataCache,\n getPrerenderResumeDataCache,\n workUnitAsyncStorage,\n} from '../app-render/work-unit-async-storage.external'\nimport { runInCleanSnapshot } from '../app-render/clean-async-snapshot.external'\n\nimport { makeHangingPromise } from '../dynamic-rendering-utils'\n\nimport type { ClientReferenceManifestForRsc } from '../../build/webpack/plugins/flight-manifest-plugin'\n\nimport {\n getClientReferenceManifestForRsc,\n getServerModuleMap,\n} from '../app-render/encryption-utils'\nimport DefaultCacheHandler from '../lib/cache-handlers/default'\nimport type { CacheHandler, 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'\n\nconst isEdgeRuntime = process.env.NEXT_RUNTIME === 'edge'\n\n// If the expire time is less than .\nconst DYNAMIC_EXPIRE = 300\n\nconst cacheHandlersSymbol = Symbol.for('@next/cache-handlers')\nconst _globalThis: typeof globalThis & {\n [cacheHandlersSymbol]?: {\n RemoteCache?: CacheHandler\n DefaultCache?: CacheHandler\n }\n __nextCacheHandlers?: Record<string, CacheHandler>\n} = globalThis\n\nconst cacheHandlerMap: Map<string, CacheHandler> = new Map([\n [\n 'default',\n _globalThis[cacheHandlersSymbol]?.DefaultCache || DefaultCacheHandler,\n ],\n [\n 'remote',\n // in dev remote maps to default handler\n // and is meant to be overridden in prod\n _globalThis[cacheHandlersSymbol]?.RemoteCache || DefaultCacheHandler,\n ],\n])\n\nfunction generateCacheEntry(\n workStore: WorkStore,\n outerWorkUnitStore: WorkUnitStore | undefined,\n clientReferenceManifest: DeepReadonly<ClientReferenceManifestForRsc>,\n encodedArguments: FormData | string,\n fn: any\n): Promise<[ReadableStream, Promise<CacheEntry>]> {\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 runInCleanSnapshot(\n generateCacheEntryWithRestoredWorkStore,\n workStore,\n outerWorkUnitStore,\n clientReferenceManifest,\n encodedArguments,\n fn\n )\n}\n\nfunction generateCacheEntryWithRestoredWorkStore(\n workStore: WorkStore,\n outerWorkUnitStore: WorkUnitStore | undefined,\n clientReferenceManifest: DeepReadonly<ClientReferenceManifestForRsc>,\n encodedArguments: FormData | string,\n fn: any\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 outerWorkUnitStore,\n clientReferenceManifest,\n encodedArguments,\n fn\n )\n}\n\nfunction generateCacheEntryWithCacheContext(\n workStore: WorkStore,\n outerWorkUnitStore: WorkUnitStore | undefined,\n clientReferenceManifest: DeepReadonly<ClientReferenceManifestForRsc>,\n encodedArguments: FormData | string,\n fn: any\n) {\n if (!workStore.cacheLifeProfiles) {\n throw new Error(\n 'cacheLifeProfiles should always be provided. This is a bug in Next.js.'\n )\n }\n const defaultCacheLife = workStore.cacheLifeProfiles['default']\n if (\n !defaultCacheLife ||\n defaultCacheLife.revalidate == null ||\n defaultCacheLife.expire == null ||\n defaultCacheLife.stale == null\n ) {\n throw new Error(\n 'A default cacheLife profile must always be provided. This is a bug in Next.js.'\n )\n }\n\n // Initialize the Store for this Cache entry.\n const cacheStore: UseCacheStore = {\n type: 'cache',\n phase: 'render',\n implicitTags:\n outerWorkUnitStore === undefined ||\n outerWorkUnitStore.type === 'unstable-cache'\n ? []\n : 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 }\n return workUnitAsyncStorage.run(\n cacheStore,\n generateCacheEntryImpl,\n workStore,\n outerWorkUnitStore,\n cacheStore,\n clientReferenceManifest,\n encodedArguments,\n fn\n )\n}\n\nfunction propagateCacheLifeAndTags(\n workUnitStore: WorkUnitStore | undefined,\n entry: CacheEntry\n): void {\n if (\n workUnitStore &&\n (workUnitStore.type === 'cache' ||\n workUnitStore.type === 'prerender' ||\n workUnitStore.type === 'prerender-ppr' ||\n workUnitStore.type === 'prerender-legacy')\n ) {\n // Propagate tags and revalidate upwards\n const outerTags = workUnitStore.tags ?? (workUnitStore.tags = [])\n const entryTags = entry.tags\n for (let i = 0; i < entryTags.length; i++) {\n const tag = entryTags[i]\n if (!outerTags.includes(tag)) {\n outerTags.push(tag)\n }\n }\n if (workUnitStore.stale > entry.stale) {\n workUnitStore.stale = entry.stale\n }\n if (workUnitStore.revalidate > entry.revalidate) {\n workUnitStore.revalidate = entry.revalidate\n }\n if (workUnitStore.expire > entry.expire) {\n workUnitStore.expire = entry.expire\n }\n }\n}\n\nasync function collectResult(\n savedStream: ReadableStream,\n outerWorkUnitStore: WorkUnitStore | undefined,\n innerCacheStore: UseCacheStore,\n startTime: number,\n errors: Array<unknown>, // This is a live array that gets pushed into.,\n timer: any\n): Promise<CacheEntry> {\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: any[] = []\n const reader = savedStream.getReader()\n for (let entry; !(entry = await reader.read()).done; ) {\n buffer.push(entry.value)\n }\n\n let idx = 0\n const bufferStream = new ReadableStream({\n pull(controller) {\n 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 = {\n value: bufferStream,\n timestamp: startTime,\n revalidate: collectedRevalidate,\n expire: collectedExpire,\n stale: collectedStale,\n tags: collectedTags === null ? [] : collectedTags,\n }\n // Propagate tags/revalidate to the parent context.\n propagateCacheLifeAndTags(outerWorkUnitStore, entry)\n\n const cacheSignal =\n outerWorkUnitStore && outerWorkUnitStore.type === 'prerender'\n ? outerWorkUnitStore.cacheSignal\n : null\n if (cacheSignal) {\n cacheSignal.endRead()\n }\n\n if (timer !== undefined) {\n clearTimeout(timer)\n }\n\n return entry\n}\n\nasync function generateCacheEntryImpl(\n workStore: WorkStore,\n outerWorkUnitStore: WorkUnitStore | undefined,\n innerCacheStore: UseCacheStore,\n clientReferenceManifest: DeepReadonly<ClientReferenceManifestForRsc>,\n encodedArguments: FormData | string,\n fn: any\n): Promise<[ReadableStream, Promise<CacheEntry>]> {\n const temporaryReferences = createServerTemporaryReferenceSet()\n\n const [, , args] = await decodeReply<any[]>(\n encodedArguments,\n getServerModuleMap(),\n {\n temporaryReferences,\n }\n )\n\n // Track the timestamp when we started copmuting the result.\n const startTime = performance.timeOrigin + performance.now()\n // Invoke the inner function to load a new result.\n const result = fn.apply(null, args)\n\n let errors: Array<unknown> = []\n\n let timer = undefined\n const controller = new AbortController()\n if (workStore.isStaticGeneration) {\n // If we're prerendering, we give you 50 seconds to fill a cache entry. Otherwise\n // we assume you stalled on hanging input and deopt. This needs to be lower than\n // just the general timeout of 60 seconds.\n timer = setTimeout(() => {\n controller.abort(\n new Error(\n 'Filling a cache during prerender timed out, likely because request-specific arguments such as ' +\n 'params, searchParams, cookies() or dynamic data were used inside \"use cache\".'\n )\n )\n }, 50000)\n }\n\n const stream = renderToReadableStream(\n result,\n clientReferenceManifest.clientModules,\n {\n environmentName: 'Cache',\n signal: controller.signal,\n temporaryReferences,\n onError(error: unknown) {\n // Report the error.\n console.error(error)\n errors.push(error)\n },\n }\n )\n\n const [returnStream, savedStream] = stream.tee()\n\n const promiseOfCacheEntry = collectResult(\n savedStream,\n outerWorkUnitStore,\n innerCacheStore,\n startTime,\n errors,\n timer\n )\n\n // Return the stream as we're creating it. This means that if it ends up\n // erroring we cannot return a stale-while-error version but it allows\n // streaming back the result earlier.\n return [returnStream, promiseOfCacheEntry]\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\nasync function clonePendingCacheEntry(\n pendingCacheEntry: Promise<CacheEntry>\n): Promise<[CacheEntry, CacheEntry]> {\n const entry = await pendingCacheEntry\n return cloneCacheEntry(entry)\n}\n\nasync function getNthCacheEntry(\n split: Promise<[CacheEntry, CacheEntry]>,\n i: number\n): Promise<CacheEntry> {\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 function cache(\n kind: string,\n id: string,\n boundArgsLength: number,\n fn: any\n) {\n if (!process.env.__NEXT_DYNAMIC_IO) {\n throw new Error(\n '\"use cache\" is only available with the experimental.dynamicIO config.'\n )\n }\n for (const [key, value] of Object.entries(\n _globalThis.__nextCacheHandlers || {}\n )) {\n cacheHandlerMap.set(key, value as CacheHandler)\n }\n const cacheHandler = cacheHandlerMap.get(kind)\n\n if (cacheHandler === undefined) {\n throw new Error('Unknown cache handler: ' + kind)\n }\n const name = fn.name\n const cachedFn = {\n [name]: async function (...args: any[]) {\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\n // Get the clientReferenceManifest while we're still in the outer Context.\n // In case getClientReferenceManifestSingleton is implemented using AsyncLocalStorage.\n const clientReferenceManifest = getClientReferenceManifestForRsc()\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 let abortHangingInputSignal: null | AbortSignal = null\n if (workUnitStore && workUnitStore.type === 'prerender') {\n // In a prerender, we may end up with hanging Promises as inputs due them stalling\n // on connection() or because they're loading dynamic data. In that case we need to\n // abort the encoding of the arguments since they'll never complete.\n const controller = new AbortController()\n abortHangingInputSignal = controller.signal\n if (workUnitStore.cacheSignal) {\n // If we have a cacheSignal it means we're in a prospective render. If the input\n // we're waiting on is coming from another cache, we do want to wait for it so that\n // we can resolve this cache entry too.\n workUnitStore.cacheSignal.inputReady().then(() => {\n controller.abort()\n })\n } else {\n // Otherwise we're in the final render and we should already have all our caches\n // filled. We might still be waiting on some microtasks so we wait one tick before\n // giving up. When we give up, we still want to render the content of this cache\n // as deeply as we can so that we can suspend as deeply as possible in the tree\n // or not at all if we don't end up waiting for the input.\n process.nextTick(() => controller.abort())\n }\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()\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 const encodedArguments: FormData | string = await encodeReply(\n [buildId, id, args],\n // Right now this is enough to cause the input to generate hanging Promises\n // but that's really due to what is probably a React bug in decodeReply.\n // If that's fixed we may need a different strategy. We can also just skip\n // the serialization/cache in this scenario and pass-through raw objects.\n abortHangingInputSignal\n ? {\n temporaryReferences,\n signal: abortHangingInputSignal,\n }\n : {\n temporaryReferences,\n }\n )\n\n const serializedCacheKey =\n typeof encodedArguments === '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 encodedArguments\n : await encodeFormData(encodedArguments)\n\n let stream: undefined | ReadableStream = undefined\n\n // Get an immutable and mutable versions of the resume data cache.\n const prerenderResumeDataCache = workUnitStore\n ? getPrerenderResumeDataCache(workUnitStore)\n : null\n const renderResumeDataCache = workUnitStore\n ? getRenderResumeDataCache(workUnitStore)\n : null\n\n if (renderResumeDataCache) {\n const cacheSignal =\n workUnitStore && workUnitStore.type === 'prerender'\n ? workUnitStore.cacheSignal\n : null\n\n if (cacheSignal) {\n cacheSignal.beginRead()\n }\n const cachedEntry = renderResumeDataCache.cache.get(serializedCacheKey)\n if (cachedEntry !== undefined) {\n const existingEntry = await cachedEntry\n propagateCacheLifeAndTags(workUnitStore, existingEntry)\n if (\n workUnitStore !== undefined &&\n workUnitStore.type === 'prerender' &&\n existingEntry !== undefined &&\n (existingEntry.revalidate === 0 ||\n existingEntry.expire < DYNAMIC_EXPIRE)\n ) {\n // In a Dynamic I/O prerender, if the cache entry has revalidate: 0 or if the\n // expire time is under 5 minutes, then we consider this cache entry dynamic\n // as it's not worth generating static pages for such data. It's better to leave\n // a PPR hole that can be filled in dynamically with a potentially cached entry.\n if (cacheSignal) {\n cacheSignal.endRead()\n }\n return makeHangingPromise(\n workUnitStore.renderSignal,\n 'dynamic \"use cache\"'\n )\n }\n const [streamA, streamB] = existingEntry.value.tee()\n existingEntry.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 if (cacheSignal) {\n cacheSignal.endRead()\n }\n }\n }\n\n if (stream === undefined) {\n const cacheSignal =\n workUnitStore && workUnitStore.type === 'prerender'\n ? workUnitStore.cacheSignal\n : null\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 implicitTags =\n workUnitStore === undefined || workUnitStore.type === 'unstable-cache'\n ? []\n : workUnitStore.implicitTags\n const entry: undefined | CacheEntry = await cacheHandler.get(\n serializedCacheKey,\n implicitTags\n )\n const currentTime = performance.timeOrigin + performance.now()\n if (\n workUnitStore !== undefined &&\n workUnitStore.type === 'prerender' &&\n entry !== undefined &&\n (entry.revalidate === 0 || entry.expire < DYNAMIC_EXPIRE)\n ) {\n // In a Dynamic I/O prerender, if the cache entry has revalidate: 0 or if the\n // expire time is under 5 minutes, then we consider this cache entry dynamic\n // as it's not worth generating static pages for such data. It's better to leave\n // a PPR hole that can be filled in dynamically with a potentially cached entry.\n if (cacheSignal) {\n cacheSignal.endRead()\n }\n\n return makeHangingPromise(\n workUnitStore.renderSignal,\n 'dynamic \"use cache\"'\n )\n } else 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 const [newStream, pendingCacheEntry] = await generateCacheEntry(\n workStore,\n workUnitStore,\n clientReferenceManifest,\n encodedArguments,\n fn\n )\n\n let savedCacheEntry\n if (prerenderResumeDataCache) {\n // Create a clone that goes into the cache scope memory cache.\n const split = clonePendingCacheEntry(pendingCacheEntry)\n savedCacheEntry = getNthCacheEntry(split, 0)\n prerenderResumeDataCache.cache.set(\n serializedCacheKey,\n getNthCacheEntry(split, 1)\n )\n } else {\n savedCacheEntry = pendingCacheEntry\n }\n\n const promise = cacheHandler.set(serializedCacheKey, savedCacheEntry)\n\n if (!workStore.pendingRevalidateWrites) {\n workStore.pendingRevalidateWrites = []\n }\n workStore.pendingRevalidateWrites.push(promise)\n\n stream = newStream\n } else {\n propagateCacheLifeAndTags(workUnitStore, entry)\n\n // We want to return this stream, even if it's stale.\n stream = entry.value\n\n // If we have a cache scope, we need to clone the entry and set it on\n // the inner cache scope.\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 prerenderResumeDataCache.cache.set(\n serializedCacheKey,\n Promise.resolve(entryRight)\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 dynamic render),\n // then we should warm up the cache with a fresh revalidated entry.\n const [ignoredStream, pendingCacheEntry] = await generateCacheEntry(\n workStore,\n undefined, // This is not running within the context of this unit.\n clientReferenceManifest,\n encodedArguments,\n fn\n )\n\n let savedCacheEntry: Promise<CacheEntry>\n if (prerenderResumeDataCache) {\n const split = clonePendingCacheEntry(pendingCacheEntry)\n savedCacheEntry = getNthCacheEntry(split, 0)\n prerenderResumeDataCache.cache.set(\n serializedCacheKey,\n getNthCacheEntry(split, 1)\n )\n } else {\n savedCacheEntry = pendingCacheEntry\n }\n\n const promise = cacheHandler.set(\n serializedCacheKey,\n savedCacheEntry\n )\n\n if (!workStore.pendingRevalidateWrites) {\n workStore.pendingRevalidateWrites = []\n }\n workStore.pendingRevalidateWrites.push(promise)\n\n await ignoredStream.cancel()\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 serverConsumerManifest,\n temporaryReferences,\n replayConsoleLogs,\n environmentName: 'Cache',\n })\n },\n }[name]\n return cachedFn\n}\n"],"names":["cache","_globalThis","isEdgeRuntime","process","env","NEXT_RUNTIME","DYNAMIC_EXPIRE","cacheHandlersSymbol","Symbol","for","globalThis","cacheHandlerMap","Map","DefaultCache","DefaultCacheHandler","RemoteCache","generateCacheEntry","workStore","outerWorkUnitStore","clientReferenceManifest","encodedArguments","fn","runInCleanSnapshot","generateCacheEntryWithRestoredWorkStore","workAsyncStorage","run","generateCacheEntryWithCacheContext","cacheLifeProfiles","Error","defaultCacheLife","revalidate","expire","stale","cacheStore","type","phase","implicitTags","undefined","explicitRevalidate","explicitExpire","explicitStale","tags","workUnitAsyncStorage","generateCacheEntryImpl","propagateCacheLifeAndTags","workUnitStore","entry","outerTags","entryTags","i","length","tag","includes","push","collectResult","savedStream","innerCacheStore","startTime","errors","timer","buffer","reader","getReader","read","done","value","idx","bufferStream","ReadableStream","pull","controller","enqueue","error","close","collectedTags","collectedRevalidate","collectedExpire","collectedStale","timestamp","cacheSignal","endRead","clearTimeout","temporaryReferences","createServerTemporaryReferenceSet","args","decodeReply","getServerModuleMap","performance","timeOrigin","now","result","apply","AbortController","isStaticGeneration","setTimeout","abort","stream","renderToReadableStream","clientModules","environmentName","signal","onError","console","returnStream","tee","promiseOfCacheEntry","cloneCacheEntry","streamA","streamB","clonedEntry","clonePendingCacheEntry","pendingCacheEntry","getNthCacheEntry","split","encodeFormData","formData","key","toString","stringValue","arrayBuffer","byteLength","String","fromCodePoint","Uint16Array","Uint8Array","createTrackedReadableStream","kind","id","boundArgsLength","__NEXT_DYNAMIC_IO","Object","entries","__nextCacheHandlers","set","cacheHandler","get","name","cachedFn","getStore","getClientReferenceManifestForRsc","buildId","abortHangingInputSignal","inputReady","then","nextTick","InvariantError","JSON","stringify","encryptedBoundArgs","shift","boundArgs","decryptActionBoundArgs","Array","isArray","unshift","createClientTemporaryReferenceSet","encodeReply","serializedCacheKey","prerenderResumeDataCache","getPrerenderResumeDataCache","renderResumeDataCache","getRenderResumeDataCache","beginRead","cachedEntry","existingEntry","makeHangingPromise","renderSignal","currentTime","newStream","savedCacheEntry","promise","pendingRevalidateWrites","entryLeft","entryRight","Promise","resolve","ignoredStream","cancel","replayConsoleLogs","serverConsumerManifest","moduleLoading","moduleMap","edgeRscModuleMapping","rscModuleMapping","serverModuleMap","createFromReadableStream"],"mappings":";;;;+BAqbgBA;;;eAAAA;;;4BA/aT;4BAMA;0CAG0B;8CAS1B;4CAC4B;uCAEA;iCAO5B;gEACyB;4BAGO;gCACR;;;;;;IAmB3BC,iCAIA,wCAAwC;AACxC,wCAAwC;AACxCA;AAvBJ,MAAMC,gBAAgBC,QAAQC,GAAG,CAACC,YAAY,KAAK;AAEnD,oCAAoC;AACpC,MAAMC,iBAAiB;AAEvB,MAAMC,sBAAsBC,OAAOC,GAAG,CAAC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_ciinfo.isCI && _ciinfo.name || null,
84
- nextVersion: "15.0.4-canary.2"
84
+ nextVersion: "15.0.4-canary.4"
85
85
  };
86
86
  return traits;
87
87
  }
@@ -11,11 +11,11 @@ Object.defineProperty(exports, "eventCliSessionStopped", {
11
11
  const EVENT_VERSION = 'NEXT_CLI_SESSION_STOPPED';
12
12
  function eventCliSessionStopped(event) {
13
13
  // This should be an invariant, if it fails our build tooling is broken.
14
- if (typeof "15.0.4-canary.2" !== 'string') {
14
+ if (typeof "15.0.4-canary.4" !== 'string') {
15
15
  return [];
16
16
  }
17
17
  const payload = {
18
- nextVersion: "15.0.4-canary.2",
18
+ nextVersion: "15.0.4-canary.4",
19
19
  nodeVersion: process.version,
20
20
  cliCommand: event.cliCommand,
21
21
  durationMilliseconds: event.durationMilliseconds,
@@ -36,12 +36,12 @@ function hasBabelConfig(dir) {
36
36
  function eventCliSession(dir, nextConfig, event) {
37
37
  var _nextConfig_experimental_staleTimes, _nextConfig_experimental_staleTimes1, _nextConfig_experimental_reactCompiler, _nextConfig_experimental_reactCompiler1;
38
38
  // This should be an invariant, if it fails our build tooling is broken.
39
- if (typeof "15.0.4-canary.2" !== 'string') {
39
+ if (typeof "15.0.4-canary.4" !== 'string') {
40
40
  return [];
41
41
  }
42
42
  const { images, i18n } = nextConfig || {};
43
43
  const payload = {
44
- nextVersion: "15.0.4-canary.2",
44
+ nextVersion: "15.0.4-canary.4",
45
45
  nodeVersion: process.version,
46
46
  cliCommand: event.cliCommand,
47
47
  isSrcDir: event.isSrcDir,
@@ -1 +1 @@
1
- export * from '../dist/experimental/testing/server'
1
+ export * from '../../dist/experimental/testing/server'
@@ -1 +1 @@
1
- module.exports = require('../dist/experimental/testing/server')
1
+ module.exports = require('../../dist/experimental/testing/server')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next",
3
- "version": "15.0.4-canary.2",
3
+ "version": "15.0.4-canary.4",
4
4
  "description": "The React Framework",
5
5
  "main": "./dist/server/next.js",
6
6
  "license": "MIT",
@@ -97,7 +97,7 @@
97
97
  ]
98
98
  },
99
99
  "dependencies": {
100
- "@next/env": "15.0.4-canary.2",
100
+ "@next/env": "15.0.4-canary.4",
101
101
  "@swc/counter": "0.1.3",
102
102
  "@swc/helpers": "0.5.13",
103
103
  "busboy": "1.6.0",
@@ -129,14 +129,14 @@
129
129
  },
130
130
  "optionalDependencies": {
131
131
  "sharp": "^0.33.5",
132
- "@next/swc-darwin-arm64": "15.0.4-canary.2",
133
- "@next/swc-darwin-x64": "15.0.4-canary.2",
134
- "@next/swc-linux-arm64-gnu": "15.0.4-canary.2",
135
- "@next/swc-linux-arm64-musl": "15.0.4-canary.2",
136
- "@next/swc-linux-x64-gnu": "15.0.4-canary.2",
137
- "@next/swc-linux-x64-musl": "15.0.4-canary.2",
138
- "@next/swc-win32-arm64-msvc": "15.0.4-canary.2",
139
- "@next/swc-win32-x64-msvc": "15.0.4-canary.2"
132
+ "@next/swc-darwin-arm64": "15.0.4-canary.4",
133
+ "@next/swc-darwin-x64": "15.0.4-canary.4",
134
+ "@next/swc-linux-arm64-gnu": "15.0.4-canary.4",
135
+ "@next/swc-linux-arm64-musl": "15.0.4-canary.4",
136
+ "@next/swc-linux-x64-gnu": "15.0.4-canary.4",
137
+ "@next/swc-linux-x64-musl": "15.0.4-canary.4",
138
+ "@next/swc-win32-arm64-msvc": "15.0.4-canary.4",
139
+ "@next/swc-win32-x64-msvc": "15.0.4-canary.4"
140
140
  },
141
141
  "devDependencies": {
142
142
  "@ampproject/toolbox-optimizer": "2.8.3",
@@ -163,17 +163,17 @@
163
163
  "@capsizecss/metrics": "3.2.0",
164
164
  "@edge-runtime/cookies": "5.0.0",
165
165
  "@edge-runtime/ponyfill": "3.0.0",
166
- "@edge-runtime/primitives": "5.0.0",
166
+ "@edge-runtime/primitives": "5.1.1",
167
167
  "@hapi/accept": "5.0.2",
168
168
  "@jest/transform": "29.5.0",
169
169
  "@jest/types": "29.5.0",
170
170
  "@mswjs/interceptors": "0.23.0",
171
171
  "@napi-rs/triples": "1.2.0",
172
- "@next/font": "15.0.4-canary.2",
173
- "@next/polyfill-module": "15.0.4-canary.2",
174
- "@next/polyfill-nomodule": "15.0.4-canary.2",
175
- "@next/react-refresh-utils": "15.0.4-canary.2",
176
- "@next/swc": "15.0.4-canary.2",
172
+ "@next/font": "15.0.4-canary.4",
173
+ "@next/polyfill-module": "15.0.4-canary.4",
174
+ "@next/polyfill-nomodule": "15.0.4-canary.4",
175
+ "@next/react-refresh-utils": "15.0.4-canary.4",
176
+ "@next/swc": "15.0.4-canary.4",
177
177
  "@opentelemetry/api": "1.6.0",
178
178
  "@playwright/test": "1.41.2",
179
179
  "@swc/core": "1.7.0-nightly-20240714.1",
@@ -250,7 +250,7 @@
250
250
  "debug": "4.1.1",
251
251
  "devalue": "2.0.1",
252
252
  "domain-browser": "4.19.0",
253
- "edge-runtime": "3.0.0",
253
+ "edge-runtime": "3.0.5",
254
254
  "events": "3.3.0",
255
255
  "find-up": "4.1.0",
256
256
  "fresh": "0.5.2",