next 15.0.4-canary.2 → 15.0.4-canary.3
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.
- package/dist/bin/next +1 -1
- package/dist/build/index.js +2 -2
- package/dist/build/swc/index.js +1 -1
- package/dist/build/webpack-config.js +2 -2
- package/dist/client/app-bootstrap.js +1 -1
- package/dist/client/index.js +1 -1
- package/dist/esm/build/index.js +2 -2
- package/dist/esm/build/swc/index.js +1 -1
- package/dist/esm/build/webpack-config.js +2 -2
- package/dist/esm/client/app-bootstrap.js +1 -1
- package/dist/esm/client/index.js +1 -1
- package/dist/esm/server/app-render/encryption.js +2 -1
- package/dist/esm/server/app-render/encryption.js.map +1 -1
- package/dist/esm/server/config.js +1 -1
- package/dist/esm/server/dev/hot-reloader-turbopack.js +1 -1
- package/dist/esm/server/dev/hot-reloader-webpack.js +1 -1
- package/dist/esm/server/lib/app-info-log.js +1 -1
- package/dist/esm/server/lib/start-server.js +1 -1
- package/dist/esm/server/use-cache/use-cache-wrapper.js +17 -1
- package/dist/esm/server/use-cache/use-cache-wrapper.js.map +1 -1
- package/dist/server/app-render/encryption.js +2 -1
- package/dist/server/app-render/encryption.js.map +1 -1
- package/dist/server/config.js +1 -1
- package/dist/server/dev/hot-reloader-turbopack.js +1 -1
- package/dist/server/dev/hot-reloader-webpack.js +1 -1
- package/dist/server/lib/app-info-log.js +1 -1
- package/dist/server/lib/start-server.js +1 -1
- package/dist/server/use-cache/use-cache-wrapper.d.ts +1 -1
- package/dist/server/use-cache/use-cache-wrapper.js +17 -1
- package/dist/server/use-cache/use-cache-wrapper.js.map +1 -1
- package/dist/telemetry/anonymous-meta.js +1 -1
- package/dist/telemetry/events/session-stopped.js +2 -2
- package/dist/telemetry/events/version.js +2 -2
- package/package.json +15 -15
package/dist/bin/next
CHANGED
|
@@ -72,7 +72,7 @@ const program = new NextRootCommand();
|
|
|
72
72
|
program.name('next').description('The Next.js CLI allows you to develop, build, start your application, and more.').configureHelp({
|
|
73
73
|
formatHelp: (cmd, helper)=>(0, _formatclihelpoutput.formatCliHelpOutput)(cmd, helper),
|
|
74
74
|
subcommandTerm: (cmd)=>`${cmd.name()} ${cmd.usage()}`
|
|
75
|
-
}).helpCommand(false).helpOption('-h, --help', 'Displays this message.').version(`Next.js v${"15.0.4-canary.
|
|
75
|
+
}).helpCommand(false).helpOption('-h, --help', 'Displays this message.').version(`Next.js v${"15.0.4-canary.3"}`, '-v, --version', 'Outputs the Next.js version.');
|
|
76
76
|
program.command('build').description('Creates an optimized production build of your application. The output displays information about each route.').argument('[directory]', `A directory on which to build the application. ${(0, _picocolors.italic)('If no directory is provided, the current directory will be used.')}`).option('-d, --debug', 'Enables a more verbose build output.').option('--no-lint', 'Disables linting.').option('--no-mangling', 'Disables mangling.').option('--profile', 'Enables production profiling for React.').option('--experimental-app-only', 'Builds only App Router routes.').addOption(new _commander.Option('--experimental-turbo').hideHelp()).addOption(new _commander.Option('--experimental-build-mode [mode]', 'Uses an experimental build mode.').choices([
|
|
77
77
|
'compile',
|
|
78
78
|
'generate'
|
package/dist/build/index.js
CHANGED
|
@@ -351,7 +351,7 @@ async function build(dir, reactProductionProfiling = false, debugOutput = false,
|
|
|
351
351
|
const nextBuildSpan = (0, _trace.trace)('next-build', undefined, {
|
|
352
352
|
buildMode: experimentalBuildMode,
|
|
353
353
|
isTurboBuild: String(turboNextBuild),
|
|
354
|
-
version: "15.0.4-canary.
|
|
354
|
+
version: "15.0.4-canary.3"
|
|
355
355
|
});
|
|
356
356
|
_buildcontext.NextBuildContext.nextBuildSpan = nextBuildSpan;
|
|
357
357
|
_buildcontext.NextBuildContext.dir = dir;
|
|
@@ -752,7 +752,7 @@ async function build(dir, reactProductionProfiling = false, debugOutput = false,
|
|
|
752
752
|
// Files outside of the distDir can be "type": "module"
|
|
753
753
|
await writeFileUtf8(_path.default.join(distDir, 'package.json'), '{"type": "commonjs"}');
|
|
754
754
|
// These are written to distDir, so they need to come after creating and cleaning distDr.
|
|
755
|
-
await (0, _builddiagnostics.recordFrameworkVersion)("15.0.4-canary.
|
|
755
|
+
await (0, _builddiagnostics.recordFrameworkVersion)("15.0.4-canary.3");
|
|
756
756
|
await (0, _builddiagnostics.updateBuildDiagnostics)({
|
|
757
757
|
buildStage: 'start'
|
|
758
758
|
});
|
package/dist/build/swc/index.js
CHANGED
|
@@ -127,7 +127,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
127
127
|
}
|
|
128
128
|
return newObj;
|
|
129
129
|
}
|
|
130
|
-
const nextVersion = "15.0.4-canary.
|
|
130
|
+
const nextVersion = "15.0.4-canary.3";
|
|
131
131
|
const ArchName = (0, _os.arch)();
|
|
132
132
|
const PlatformName = (0, _os.platform)();
|
|
133
133
|
function infoLog(...args) {
|
|
@@ -1508,7 +1508,7 @@ async function getBaseWebpackConfig(dir, { buildId, encryptionKey, config, compi
|
|
|
1508
1508
|
isClient && new _copyfileplugin.CopyFilePlugin({
|
|
1509
1509
|
// file path to build output of `@next/polyfill-nomodule`
|
|
1510
1510
|
filePath: require.resolve('./polyfills/polyfill-nomodule'),
|
|
1511
|
-
cacheKey: "15.0.4-canary.
|
|
1511
|
+
cacheKey: "15.0.4-canary.3",
|
|
1512
1512
|
name: `static/chunks/polyfills${dev ? '' : '-[hash]'}.js`,
|
|
1513
1513
|
minimize: false,
|
|
1514
1514
|
info: {
|
|
@@ -1736,7 +1736,7 @@ async function getBaseWebpackConfig(dir, { buildId, encryptionKey, config, compi
|
|
|
1736
1736
|
// - Next.js location on disk (some loaders use absolute paths and some resolve options depend on absolute paths)
|
|
1737
1737
|
// - Next.js version
|
|
1738
1738
|
// - next.config.js keys that affect compilation
|
|
1739
|
-
version: `${__dirname}|${"15.0.4-canary.
|
|
1739
|
+
version: `${__dirname}|${"15.0.4-canary.3"}|${configVars}`,
|
|
1740
1740
|
cacheDirectory: _path.default.join(distDir, 'cache', 'webpack'),
|
|
1741
1741
|
// For production builds, it's more efficient to compress all cache files together instead of compression each one individually.
|
|
1742
1742
|
// So we disable compression here and allow the build runner to take care of compressing the cache as a whole.
|
package/dist/client/index.js
CHANGED
|
@@ -61,7 +61,7 @@ const _hooksclientcontextsharedruntime = require("../shared/lib/hooks-client-con
|
|
|
61
61
|
const _shared = require("./react-client-callbacks/shared");
|
|
62
62
|
const _tracer = /*#__PURE__*/ _interop_require_default._(require("./tracing/tracer"));
|
|
63
63
|
const _reporttosocket = /*#__PURE__*/ _interop_require_default._(require("./tracing/report-to-socket"));
|
|
64
|
-
const version = "15.0.4-canary.
|
|
64
|
+
const version = "15.0.4-canary.3";
|
|
65
65
|
let router;
|
|
66
66
|
const emitter = (0, _mitt.default)();
|
|
67
67
|
const looseToArray = (input)=>[].slice.call(input);
|
package/dist/esm/build/index.js
CHANGED
|
@@ -283,7 +283,7 @@ export default async function build(dir, reactProductionProfiling = false, debug
|
|
|
283
283
|
const nextBuildSpan = trace('next-build', undefined, {
|
|
284
284
|
buildMode: experimentalBuildMode,
|
|
285
285
|
isTurboBuild: String(turboNextBuild),
|
|
286
|
-
version: "15.0.4-canary.
|
|
286
|
+
version: "15.0.4-canary.3"
|
|
287
287
|
});
|
|
288
288
|
NextBuildContext.nextBuildSpan = nextBuildSpan;
|
|
289
289
|
NextBuildContext.dir = dir;
|
|
@@ -684,7 +684,7 @@ export default async function build(dir, reactProductionProfiling = false, debug
|
|
|
684
684
|
// Files outside of the distDir can be "type": "module"
|
|
685
685
|
await writeFileUtf8(path.join(distDir, 'package.json'), '{"type": "commonjs"}');
|
|
686
686
|
// These are written to distDir, so they need to come after creating and cleaning distDr.
|
|
687
|
-
await recordFrameworkVersion("15.0.4-canary.
|
|
687
|
+
await recordFrameworkVersion("15.0.4-canary.3");
|
|
688
688
|
await updateBuildDiagnostics({
|
|
689
689
|
buildStage: 'start'
|
|
690
690
|
});
|
|
@@ -11,7 +11,7 @@ import { isDeepStrictEqual } from 'util';
|
|
|
11
11
|
import { getDefineEnv } from '../webpack/plugins/define-env-plugin';
|
|
12
12
|
import { getReactCompilerLoader } from '../get-babel-loader-config';
|
|
13
13
|
import { TurbopackInternalError } from '../../server/dev/turbopack-utils';
|
|
14
|
-
const nextVersion = "15.0.4-canary.
|
|
14
|
+
const nextVersion = "15.0.4-canary.3";
|
|
15
15
|
const ArchName = arch();
|
|
16
16
|
const PlatformName = platform();
|
|
17
17
|
function infoLog(...args) {
|
|
@@ -1409,7 +1409,7 @@ export default async function getBaseWebpackConfig(dir, { buildId, encryptionKey
|
|
|
1409
1409
|
isClient && new CopyFilePlugin({
|
|
1410
1410
|
// file path to build output of `@next/polyfill-nomodule`
|
|
1411
1411
|
filePath: require.resolve('./polyfills/polyfill-nomodule'),
|
|
1412
|
-
cacheKey: "15.0.4-canary.
|
|
1412
|
+
cacheKey: "15.0.4-canary.3",
|
|
1413
1413
|
name: `static/chunks/polyfills${dev ? '' : '-[hash]'}.js`,
|
|
1414
1414
|
minimize: false,
|
|
1415
1415
|
info: {
|
|
@@ -1637,7 +1637,7 @@ export default async function getBaseWebpackConfig(dir, { buildId, encryptionKey
|
|
|
1637
1637
|
// - Next.js location on disk (some loaders use absolute paths and some resolve options depend on absolute paths)
|
|
1638
1638
|
// - Next.js version
|
|
1639
1639
|
// - next.config.js keys that affect compilation
|
|
1640
|
-
version: `${__dirname}|${"15.0.4-canary.
|
|
1640
|
+
version: `${__dirname}|${"15.0.4-canary.3"}|${configVars}`,
|
|
1641
1641
|
cacheDirectory: path.join(distDir, 'cache', 'webpack'),
|
|
1642
1642
|
// For production builds, it's more efficient to compress all cache files together instead of compression each one individually.
|
|
1643
1643
|
// So we disable compression here and allow the build runner to take care of compressing the cache as a whole.
|
package/dist/esm/client/index.js
CHANGED
|
@@ -26,7 +26,7 @@ import { SearchParamsContext, PathParamsContext } from '../shared/lib/hooks-clie
|
|
|
26
26
|
import { onRecoverableError } from './react-client-callbacks/shared';
|
|
27
27
|
import tracer from './tracing/tracer';
|
|
28
28
|
import reportToSocket from './tracing/report-to-socket';
|
|
29
|
-
export const version = "15.0.4-canary.
|
|
29
|
+
export const version = "15.0.4-canary.3";
|
|
30
30
|
export let router;
|
|
31
31
|
export const emitter = mitt();
|
|
32
32
|
const looseToArray = (input)=>[].slice.call(input);
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
/* eslint-disable import/no-extraneous-dependencies */ import { createFromReadableStream } from 'react-server-dom-webpack/client.edge';
|
|
4
4
|
import { streamToString } from '../stream-utils/node-web-streams-helper';
|
|
5
5
|
import { arrayBufferToString, decrypt, encrypt, getActionEncryptionKey, getClientReferenceManifestForRsc, getServerModuleMap, stringToUint8Array } from './encryption-utils';
|
|
6
|
+
import { workUnitAsyncStorage } from './work-unit-async-storage.external';
|
|
6
7
|
const isEdgeRuntime = process.env.NEXT_RUNTIME === 'edge';
|
|
7
8
|
const textEncoder = new TextEncoder();
|
|
8
9
|
const textDecoder = new TextDecoder();
|
|
@@ -28,7 +29,7 @@ async function encodeActionBoundArg(actionId, arg) {
|
|
|
28
29
|
}
|
|
29
30
|
// Get 16 random bytes as iv.
|
|
30
31
|
const randomBytes = new Uint8Array(16);
|
|
31
|
-
crypto.getRandomValues(randomBytes);
|
|
32
|
+
workUnitAsyncStorage.exit(()=>crypto.getRandomValues(randomBytes));
|
|
32
33
|
const ivValue = arrayBufferToString(randomBytes.buffer);
|
|
33
34
|
const encrypted = await encrypt(key, randomBytes, textEncoder.encode(actionId + arg));
|
|
34
35
|
return btoa(ivValue + arrayBufferToString(encrypted));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/server/app-render/encryption.ts"],"sourcesContent":["/* eslint-disable import/no-extraneous-dependencies */\nimport 'server-only'\n\n/* eslint-disable import/no-extraneous-dependencies */\nimport { renderToReadableStream } from 'react-server-dom-webpack/server.edge'\n/* eslint-disable import/no-extraneous-dependencies */\nimport { createFromReadableStream } from 'react-server-dom-webpack/client.edge'\n\nimport { streamToString } from '../stream-utils/node-web-streams-helper'\nimport {\n arrayBufferToString,\n decrypt,\n encrypt,\n getActionEncryptionKey,\n getClientReferenceManifestForRsc,\n getServerModuleMap,\n stringToUint8Array,\n} from './encryption-utils'\n\nconst isEdgeRuntime = process.env.NEXT_RUNTIME === 'edge'\n\nconst textEncoder = new TextEncoder()\nconst textDecoder = new TextDecoder()\n\nasync function decodeActionBoundArg(actionId: string, arg: string) {\n const key = await getActionEncryptionKey()\n if (typeof key === 'undefined') {\n throw new Error(\n `Missing encryption key for Server Action. This is a bug in Next.js`\n )\n }\n\n // Get the iv (16 bytes) and the payload from the arg.\n const originalPayload = atob(arg)\n const ivValue = originalPayload.slice(0, 16)\n const payload = originalPayload.slice(16)\n\n const decrypted = textDecoder.decode(\n await decrypt(key, stringToUint8Array(ivValue), stringToUint8Array(payload))\n )\n\n if (!decrypted.startsWith(actionId)) {\n throw new Error('Invalid Server Action payload: failed to decrypt.')\n }\n\n return decrypted.slice(actionId.length)\n}\n\nasync function encodeActionBoundArg(actionId: string, arg: string) {\n const key = await getActionEncryptionKey()\n if (key === undefined) {\n throw new Error(\n `Missing encryption key for Server Action. This is a bug in Next.js`\n )\n }\n\n // Get 16 random bytes as iv.\n const randomBytes = new Uint8Array(16)\n crypto.getRandomValues(randomBytes)\n const ivValue = arrayBufferToString(randomBytes.buffer)\n\n const encrypted = await encrypt(\n key,\n randomBytes,\n textEncoder.encode(actionId + arg)\n )\n\n return btoa(ivValue + arrayBufferToString(encrypted))\n}\n\n// Encrypts the action's bound args into a string.\nexport async function encryptActionBoundArgs(actionId: string, args: any[]) {\n const { clientModules } = getClientReferenceManifestForRsc()\n\n // Using Flight to serialize the args into a string.\n const serialized = await streamToString(\n renderToReadableStream(args, clientModules)\n )\n\n // Encrypt the serialized string with the action id as the salt.\n // Add a prefix to later ensure that the payload is correctly decrypted, similar\n // to a checksum.\n const encrypted = await encodeActionBoundArg(actionId, serialized)\n\n return encrypted\n}\n\n// Decrypts the action's bound args from the encrypted string.\nexport async function decryptActionBoundArgs(\n actionId: string,\n encrypted: Promise<string>\n) {\n const { edgeRscModuleMapping, rscModuleMapping } =\n getClientReferenceManifestForRsc()\n\n // Decrypt the serialized string with the action id as the salt.\n const decrypted = await decodeActionBoundArg(actionId, await encrypted)\n\n // Using Flight to deserialize the args from the string.\n const deserialized = await createFromReadableStream(\n new ReadableStream({\n start(controller) {\n controller.enqueue(textEncoder.encode(decrypted))\n controller.close()\n },\n }),\n {\n serverConsumerManifest: {\n // moduleLoading must be null because we don't want to trigger preloads of ClientReferences\n // to be added to the current execution. Instead, we'll wait for any ClientReference\n // to be emitted which themselves will handle the preloading.\n moduleLoading: null,\n moduleMap: isEdgeRuntime ? edgeRscModuleMapping : rscModuleMapping,\n serverModuleMap: getServerModuleMap(),\n },\n }\n )\n\n return deserialized\n}\n"],"names":["renderToReadableStream","createFromReadableStream","streamToString","arrayBufferToString","decrypt","encrypt","getActionEncryptionKey","getClientReferenceManifestForRsc","getServerModuleMap","stringToUint8Array","isEdgeRuntime","process","env","NEXT_RUNTIME","textEncoder","TextEncoder","textDecoder","TextDecoder","decodeActionBoundArg","actionId","arg","key","Error","originalPayload","atob","ivValue","slice","payload","decrypted","decode","startsWith","length","encodeActionBoundArg","undefined","randomBytes","Uint8Array","crypto","getRandomValues","buffer","encrypted","encode","btoa","encryptActionBoundArgs","args","clientModules","serialized","decryptActionBoundArgs","edgeRscModuleMapping","rscModuleMapping","deserialized","ReadableStream","start","controller","enqueue","close","serverConsumerManifest","moduleLoading","moduleMap","serverModuleMap"],"mappings":"AAAA,oDAAoD,GACpD,OAAO,cAAa;AAEpB,oDAAoD,GACpD,SAASA,sBAAsB,QAAQ,uCAAsC;AAC7E,oDAAoD,GACpD,SAASC,wBAAwB,QAAQ,uCAAsC;AAE/E,SAASC,cAAc,QAAQ,0CAAyC;AACxE,SACEC,mBAAmB,EACnBC,OAAO,EACPC,OAAO,EACPC,sBAAsB,EACtBC,gCAAgC,EAChCC,kBAAkB,EAClBC,kBAAkB,QACb,qBAAoB;
|
|
1
|
+
{"version":3,"sources":["../../../src/server/app-render/encryption.ts"],"sourcesContent":["/* eslint-disable import/no-extraneous-dependencies */\nimport 'server-only'\n\n/* eslint-disable import/no-extraneous-dependencies */\nimport { renderToReadableStream } from 'react-server-dom-webpack/server.edge'\n/* eslint-disable import/no-extraneous-dependencies */\nimport { createFromReadableStream } from 'react-server-dom-webpack/client.edge'\n\nimport { streamToString } from '../stream-utils/node-web-streams-helper'\nimport {\n arrayBufferToString,\n decrypt,\n encrypt,\n getActionEncryptionKey,\n getClientReferenceManifestForRsc,\n getServerModuleMap,\n stringToUint8Array,\n} from './encryption-utils'\nimport { workUnitAsyncStorage } from './work-unit-async-storage.external'\n\nconst isEdgeRuntime = process.env.NEXT_RUNTIME === 'edge'\n\nconst textEncoder = new TextEncoder()\nconst textDecoder = new TextDecoder()\n\nasync function decodeActionBoundArg(actionId: string, arg: string) {\n const key = await getActionEncryptionKey()\n if (typeof key === 'undefined') {\n throw new Error(\n `Missing encryption key for Server Action. This is a bug in Next.js`\n )\n }\n\n // Get the iv (16 bytes) and the payload from the arg.\n const originalPayload = atob(arg)\n const ivValue = originalPayload.slice(0, 16)\n const payload = originalPayload.slice(16)\n\n const decrypted = textDecoder.decode(\n await decrypt(key, stringToUint8Array(ivValue), stringToUint8Array(payload))\n )\n\n if (!decrypted.startsWith(actionId)) {\n throw new Error('Invalid Server Action payload: failed to decrypt.')\n }\n\n return decrypted.slice(actionId.length)\n}\n\nasync function encodeActionBoundArg(actionId: string, arg: string) {\n const key = await getActionEncryptionKey()\n if (key === undefined) {\n throw new Error(\n `Missing encryption key for Server Action. This is a bug in Next.js`\n )\n }\n\n // Get 16 random bytes as iv.\n const randomBytes = new Uint8Array(16)\n workUnitAsyncStorage.exit(() => crypto.getRandomValues(randomBytes))\n const ivValue = arrayBufferToString(randomBytes.buffer)\n\n const encrypted = await encrypt(\n key,\n randomBytes,\n textEncoder.encode(actionId + arg)\n )\n\n return btoa(ivValue + arrayBufferToString(encrypted))\n}\n\n// Encrypts the action's bound args into a string.\nexport async function encryptActionBoundArgs(actionId: string, args: any[]) {\n const { clientModules } = getClientReferenceManifestForRsc()\n\n // Using Flight to serialize the args into a string.\n const serialized = await streamToString(\n renderToReadableStream(args, clientModules)\n )\n\n // Encrypt the serialized string with the action id as the salt.\n // Add a prefix to later ensure that the payload is correctly decrypted, similar\n // to a checksum.\n const encrypted = await encodeActionBoundArg(actionId, serialized)\n\n return encrypted\n}\n\n// Decrypts the action's bound args from the encrypted string.\nexport async function decryptActionBoundArgs(\n actionId: string,\n encrypted: Promise<string>\n) {\n const { edgeRscModuleMapping, rscModuleMapping } =\n getClientReferenceManifestForRsc()\n\n // Decrypt the serialized string with the action id as the salt.\n const decrypted = await decodeActionBoundArg(actionId, await encrypted)\n\n // Using Flight to deserialize the args from the string.\n const deserialized = await createFromReadableStream(\n new ReadableStream({\n start(controller) {\n controller.enqueue(textEncoder.encode(decrypted))\n controller.close()\n },\n }),\n {\n serverConsumerManifest: {\n // moduleLoading must be null because we don't want to trigger preloads of ClientReferences\n // to be added to the current execution. Instead, we'll wait for any ClientReference\n // to be emitted which themselves will handle the preloading.\n moduleLoading: null,\n moduleMap: isEdgeRuntime ? edgeRscModuleMapping : rscModuleMapping,\n serverModuleMap: getServerModuleMap(),\n },\n }\n )\n\n return deserialized\n}\n"],"names":["renderToReadableStream","createFromReadableStream","streamToString","arrayBufferToString","decrypt","encrypt","getActionEncryptionKey","getClientReferenceManifestForRsc","getServerModuleMap","stringToUint8Array","workUnitAsyncStorage","isEdgeRuntime","process","env","NEXT_RUNTIME","textEncoder","TextEncoder","textDecoder","TextDecoder","decodeActionBoundArg","actionId","arg","key","Error","originalPayload","atob","ivValue","slice","payload","decrypted","decode","startsWith","length","encodeActionBoundArg","undefined","randomBytes","Uint8Array","exit","crypto","getRandomValues","buffer","encrypted","encode","btoa","encryptActionBoundArgs","args","clientModules","serialized","decryptActionBoundArgs","edgeRscModuleMapping","rscModuleMapping","deserialized","ReadableStream","start","contro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AI,CAAC,IAAMC,OAAOC,eAAe,CAACJ;IACvD,MAAMT,UAAUvB,oBAAoBgC,YAAYK,MAAM;IAEtD,MAAMC,YAAY,MAAMpC,QACtBiB,KACAa,aACApB,YAAY2B,MAAM,CAACtB,WAAWC;IAGhC,OAAOsB,KAAKjB,UAAUvB,oBAAoBsC;AAC5C;AAEA,kDAAkD;AAClD,OAAO,eAAeG,uBAAuBxB,QAAgB,EAAEyB,IAAW;IACxE,MAAM,EAAEC,aAAa,EAAE,GAAGvC;IAE1B,oDAAoD;IACpD,MAAMwC,aAAa,MAAM7C,eACvBF,uBAAuB6C,MAAMC;IAG/B,gEAAgE;IAChE,gFAAgF;IAChF,iBAAiB;IACjB,MAAML,YAAY,MAAMR,qBAAqBb,UAAU2B;IAEvD,OAAON;AACT;AAEA,8DAA8D;AAC9D,OAAO,eAAeO,uBACpB5B,QAAgB,EAChBqB,SAA0B;IAE1B,MAAM,EAAEQ,oBAAoB,EAAEC,gBAAgB,EAAE,GAC9C3C;IAEF,gEAAgE;IAChE,MAAMsB,YAAY,MAAMV,qBAAqBC,UAAU,MAAMqB;IAE7D,wDAAwD;IACxD,MAAMU,eAAe,MAAMlD,yBACzB,IAAImD,eAAe;QACjBC,OAAMC,UAAU;YACdA,WAAWC,OAAO,CAACxC,YAAY2B,MAAM,CAACb;YACtCyB,WAAWE,KAAK;QAClB;IACF,IACA;QACEC,wBAAwB;YACtB,2FAA2F;YAC3F,oFAAoF;YACpF,6DAA6D;YAC7DC,eAAe;YACfC,WAAWhD,gBAAgBsC,uBAAuBC;YAClDU,iBAAiBpD;QACnB;IACF;IAGF,OAAO2C;AACT"}
|
|
@@ -155,7 +155,7 @@ function assignDefaults(dir, userConfig, silent) {
|
|
|
155
155
|
if (((_result_experimental = result.experimental) == null ? void 0 : _result_experimental.allowDevelopmentBuild) && process.env.NODE_ENV !== 'development') {
|
|
156
156
|
throw new Error(`The experimental.allowDevelopmentBuild option requires NODE_ENV to be explicitly set to 'development'.`);
|
|
157
157
|
}
|
|
158
|
-
if (!((_process_env___NEXT_VERSION = "15.0.4-canary.
|
|
158
|
+
if (!((_process_env___NEXT_VERSION = "15.0.4-canary.3") == null ? void 0 : _process_env___NEXT_VERSION.includes('canary')) && !process.env.__NEXT_TEST_MODE && !process.env.NEXT_PRIVATE_SKIP_CANARY_CHECK) {
|
|
159
159
|
var _result_experimental7, _result_experimental8, _result_experimental_turbo3, _result_experimental9;
|
|
160
160
|
// Prevents usage of certain experimental features outside of canary
|
|
161
161
|
if ((_result_experimental7 = result.experimental) == null ? void 0 : _result_experimental7.ppr) {
|
|
@@ -48,7 +48,7 @@ export async function createHotReloaderTurbopack(opts, serverFields, distDir, re
|
|
|
48
48
|
}
|
|
49
49
|
const hasRewrites = opts.fsChecker.rewrites.afterFiles.length > 0 || opts.fsChecker.rewrites.beforeFiles.length > 0 || opts.fsChecker.rewrites.fallback.length > 0;
|
|
50
50
|
const hotReloaderSpan = trace('hot-reloader', undefined, {
|
|
51
|
-
version: "15.0.4-canary.
|
|
51
|
+
version: "15.0.4-canary.3"
|
|
52
52
|
});
|
|
53
53
|
// Ensure the hotReloaderSpan is flushed immediately as it's the parentSpan for all processing
|
|
54
54
|
// of the current `next dev` invocation.
|
|
@@ -184,7 +184,7 @@ export default class HotReloaderWebpack {
|
|
|
184
184
|
this.previewProps = previewProps;
|
|
185
185
|
this.rewrites = rewrites;
|
|
186
186
|
this.hotReloaderSpan = trace('hot-reloader', undefined, {
|
|
187
|
-
version: "15.0.4-canary.
|
|
187
|
+
version: "15.0.4-canary.3"
|
|
188
188
|
});
|
|
189
189
|
// Ensure the hotReloaderSpan is flushed immediately as it's the parentSpan for all processing
|
|
190
190
|
// of the current `next dev` invocation.
|
|
@@ -4,7 +4,7 @@ import { bold, purple } from '../../lib/picocolors';
|
|
|
4
4
|
import { PHASE_DEVELOPMENT_SERVER, PHASE_PRODUCTION_BUILD } from '../../shared/lib/constants';
|
|
5
5
|
import loadConfig, { getEnabledExperimentalFeatures } from '../config';
|
|
6
6
|
export function logStartInfo({ networkUrl, appUrl, envInfo, expFeatureInfo, maxExperimentalFeatures = Infinity }) {
|
|
7
|
-
Log.bootstrap(`${bold(purple(`${Log.prefixes.ready} Next.js ${"15.0.4-canary.
|
|
7
|
+
Log.bootstrap(`${bold(purple(`${Log.prefixes.ready} Next.js ${"15.0.4-canary.3"}`))}${process.env.TURBOPACK ? ' (Turbopack)' : ''}`);
|
|
8
8
|
if (appUrl) {
|
|
9
9
|
Log.bootstrap(`- Local: ${appUrl}`);
|
|
10
10
|
}
|
|
@@ -40,7 +40,7 @@ export async function getRequestHandlers({ dir, port, isDev, onCleanup, server,
|
|
|
40
40
|
export async function startServer(serverOptions) {
|
|
41
41
|
const { dir, isDev, hostname, minimalMode, allowRetry, keepAliveTimeout, selfSignedCertificate } = serverOptions;
|
|
42
42
|
let { port } = serverOptions;
|
|
43
|
-
process.title = `next-server (v${"15.0.4-canary.
|
|
43
|
+
process.title = `next-server (v${"15.0.4-canary.3"})`;
|
|
44
44
|
let handlersReady = ()=>{};
|
|
45
45
|
let handlersError = ()=>{};
|
|
46
46
|
let handlersPromise = new Promise((resolve, reject)=>{
|
|
@@ -9,6 +9,8 @@ import { runInCleanSnapshot } from '../app-render/clean-async-snapshot.external'
|
|
|
9
9
|
import { makeHangingPromise } from '../dynamic-rendering-utils';
|
|
10
10
|
import { getClientReferenceManifestForRsc, getServerModuleMap } from '../app-render/encryption-utils';
|
|
11
11
|
import DefaultCacheHandler from '../lib/cache-handlers/default';
|
|
12
|
+
import { decryptActionBoundArgs } from '../app-render/encryption';
|
|
13
|
+
import { InvariantError } from '../../shared/lib/invariant-error';
|
|
12
14
|
const isEdgeRuntime = process.env.NEXT_RUNTIME === 'edge';
|
|
13
15
|
// If the expire time is less than .
|
|
14
16
|
const DYNAMIC_EXPIRE = 300;
|
|
@@ -248,7 +250,7 @@ function createTrackedReadableStream(stream, cacheSignal) {
|
|
|
248
250
|
}
|
|
249
251
|
});
|
|
250
252
|
}
|
|
251
|
-
export function cache(kind, id, fn) {
|
|
253
|
+
export function cache(kind, id, boundArgsLength, fn) {
|
|
252
254
|
if (!process.env.__NEXT_DYNAMIC_IO) {
|
|
253
255
|
throw new Error('"use cache" is only available with the experimental.dynamicIO config.');
|
|
254
256
|
}
|
|
@@ -298,6 +300,20 @@ export function cache(kind, id, fn) {
|
|
|
298
300
|
process.nextTick(()=>controller.abort());
|
|
299
301
|
}
|
|
300
302
|
}
|
|
303
|
+
if (boundArgsLength > 0) {
|
|
304
|
+
if (args.length === 0) {
|
|
305
|
+
throw new InvariantError(`Expected the "use cache" function ${JSON.stringify(fn.name)} to receive its encrypted bound arguments as the first argument.`);
|
|
306
|
+
}
|
|
307
|
+
const encryptedBoundArgs = args.shift();
|
|
308
|
+
const boundArgs = await decryptActionBoundArgs(id, encryptedBoundArgs);
|
|
309
|
+
if (!Array.isArray(boundArgs)) {
|
|
310
|
+
throw new InvariantError(`Expected the bound arguments of "use cache" function ${JSON.stringify(fn.name)} to deserialize into an array, got ${typeof boundArgs} instead.`);
|
|
311
|
+
}
|
|
312
|
+
if (boundArgsLength !== boundArgs.length) {
|
|
313
|
+
throw new InvariantError(`Expected the "use cache" function ${JSON.stringify(fn.name)} to receive ${boundArgsLength} bound arguments, got ${boundArgs.length} instead.`);
|
|
314
|
+
}
|
|
315
|
+
args.unshift(...boundArgs);
|
|
316
|
+
}
|
|
301
317
|
const temporaryReferences = createClientTemporaryReferenceSet();
|
|
302
318
|
const encodedArguments = await encodeReply([
|
|
303
319
|
buildId,
|
|
@@ -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":["_globalThis","renderToReadableStream","decodeReply","createTemporaryReferenceSet","createServerTemporaryReferenceSet","createFromReadableStream","encodeReply","createClientTemporaryReferenceSet","workAsyncStorage","getRenderResumeDataCache","getPrerenderResumeDataCache","workUnitAsyncStorage","runInCleanSnapshot","makeHangingPromise","getClientReferenceManifestForRsc","getServerModuleMap","DefaultCacheHandler","isEdgeRuntime","process","env","NEXT_RUNTIME","DYNAMIC_EXPIRE","cacheHandlersSymbol","Symbol","for","globalThis","cacheHandlerMap","Map","DefaultCache","RemoteCache","generateCacheEntry","workStore","outerWorkUnitStore","clientReferenceManifest","encodedArguments","fn","generateCacheEntryWithRestoredWorkStore","run","generateCacheEntryWithCacheContext","cacheLifeProfiles","Error","defaultCacheLife","revalidate","expire","stale","cacheStore","type","phase","implicitTags","undefined","explicitRevalidate","explicitExpire","explicitStale","tags","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","args","performance","timeOrigin","now","result","apply","AbortController","isStaticGeneration","setTimeout","abort","stream","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","cache","kind","id","__NEXT_DYNAMIC_IO","Object","entries","__nextCacheHandlers","set","cacheHandler","get","name","cachedFn","getStore","buildId","abortHangingInputSignal","inputReady","then","nextTick","serializedCacheKey","prerenderResumeDataCache","renderResumeDataCache","beginRead","cachedEntry","existingEntry","renderSignal","currentTime","newStream","savedCacheEntry","promise","pendingRevalidateWrites","entryLeft","entryRight","Promise","resolve","ignoredStream","cancel","replayConsoleLogs","serverConsumerManifest","moduleLoading","moduleMap","edgeRscModuleMapping","rscModuleMapping","serverModuleMap"],"mappings":"IAwDIA,iCAIA,wCAAwC;AACxC,wCAAwC;AACxCA;AA7DJ,oDAAoD,GACpD,SACEC,sBAAsB,EACtBC,WAAW,EACXC,+BAA+BC,iCAAiC,QAC3D,uCAAsC;AAC7C,oDAAoD,GACpD,SACEC,wBAAwB,EACxBC,WAAW,EACXH,+BAA+BI,iCAAiC,QAC3D,uCAAsC;AAG7C,SAASC,gBAAgB,QAAQ,4CAA2C;AAK5E,SACEC,wBAAwB,EACxBC,2BAA2B,EAC3BC,oBAAoB,QACf,iDAAgD;AACvD,SAASC,kBAAkB,QAAQ,8CAA6C;AAEhF,SAASC,kBAAkB,QAAQ,6BAA4B;AAI/D,SACEC,gCAAgC,EAChCC,kBAAkB,QACb,iCAAgC;AACvC,OAAOC,yBAAyB,gCAA+B;AAI/D,MAAMC,gBAAgBC,QAAQC,GAAG,CAACC,YAAY,KAAK;AAEnD,oCAAoC;AACpC,MAAMC,iBAAiB;AAEvB,MAAMC,sBAAsBC,OAAOC,GAAG,CAAC;AACvC,MAAMxB,cAMFyB;AAEJ,MAAMC,kBAA6C,IAAIC,IAAI;IACzD;QACE;QACA3B,EAAAA,kCAAAA,WAAW,CAACsB,oBAAoB,qBAAhCtB,gCAAkC4B,YAAY,KAAIZ;KACnD;IACD;Q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-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":["_globalThis","renderToReadableStream","decodeReply","createTemporaryReferenceSet","createServerTemporaryReferenceSet","createFromReadableStream","encodeReply","createClientTemporaryReferenceSet","workAsyncStorage","getRenderResumeDataCache","getPrerenderResumeDataCache","workUnitAsyncStorage","runInCleanSnapshot","makeHangingPromise","getClientReferenceManifestForRsc","getServerModuleMap","DefaultCacheHandler","decryptActionBoundArgs","InvariantError","isEdgeRuntime","process","env","NEXT_RUNTIME","DYNAMIC_EXPIRE","cacheHandlersSymbol","Symbol","for","globalThis","cacheHandlerMap","Map","DefaultCache","RemoteCache","generateCacheEntry","workStore","outerWorkUnitStore","clientReferenceManifest","encodedArguments","fn","generateCacheEntryWithRestoredWorkStore","run","generateCacheEntryWithCacheContext","cacheLifeProfiles","Error","defaultCacheLife","revalidate","expire","stale","cacheStore","type","phase","implicitTags","undefined","explicitRevalidate","explicitExpire","explicitStale","tags","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","args","performance","timeOrigin","now","result","apply","AbortController","isStaticGeneration","setTimeout","abort","stream","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","cache","kind","id","boundArgsLength","__NEXT_DYNAMIC_IO","Object","entries","__nextCacheHandlers","set","cacheHandler","get","name","cachedFn","getStore","buildId","abortHangingInputSignal","inputReady","then","nextTick","JSON","stringify","encryptedBoundArgs","shift","boundArgs","Array","isArray","unshift","serializedCacheKey","prerenderResumeDataCache","renderResumeDataCache","beginRead","cachedEntry","existingEntry","renderSignal","currentTime","newStream","savedCacheEntry","promise","pendingRevalidateWrites","entryLeft","entryRight","Promise","resolve","ignoredStream","cancel","replayConsoleLogs","serverConsumerManifest","moduleLoading","moduleMap","edgeRscModuleMapping","rscModuleMapping","serverModuleMap"],"mappings":"IA0DIA,iCAIA,wCAAwC;AACxC,wCAAwC;AACxCA;AA/DJ,oDAAoD,GACpD,SACEC,sBAAsB,EACtBC,WAAW,EACXC,+BAA+BC,iCAAiC,QAC3D,uCAAsC;AAC7C,oDAAoD,GACpD,SACEC,wBAAwB,EACxBC,WAAW,EACXH,+BAA+BI,iCAAiC,QAC3D,uCAAsC;AAG7C,SAASC,gBAAgB,QAAQ,4CAA2C;AAK5E,SACEC,wBAAwB,EACxBC,2BAA2B,EAC3BC,oBAAoB,QACf,iDAAgD;AACvD,SAASC,kBAAkB,QAAQ,8CAA6C;AAEhF,SAASC,kBAAkB,QAAQ,6BAA4B;AAI/D,SACEC,gCAAgC,EAChCC,kBAAkB,QACb,iCAAgC;AACvC,OAAOC,yBAAyB,gCAA+B;AAG/D,SAASC,sBAAsB,QAAQ,2BAA0B;AACjE,SAASC,cAAc,QAAQ,mCAAkC;AAEjE,MAAMC,gBAAgBC,QAAQC,GAAG,CAACC,YAAY,KAAK;AAEnD,oCAAoC;AACpC,MAAMC,iBAAiB;AAEvB,MAAMC,sBAAsBC,OAAOC,GAAG,CAAC;AACvC,MAAM1B,cAMF2B;AAEJ,MAAMC,kBAA6C,IAAIC,IAAI;IACzD;QACE;QACA7B,EAAAA,kCAAAA,WAAW,CAACwB,oBAAoB,qBAAhCxB,gCAAkC8B,YAAY,KAAId;KACnD;IACD;QACE;QAGAhB,EAAAA,mCAAAA,WAAW,CAACwB,oBAAoB,qBAAhCxB,iCAAkC+B,WAAW,KAAIf;KAClD;CACF;AAED,SAASgB,mBACPC,SAAoB,EACpBC,kBAA6C,EAC7CC,uBAAoE,EACpEC,gBAAmC,EACnCC,EAAO;IAEP,kFAAkF;IAClF,mFAAmF;IACnF,+EAA+E;IAC/E,mFAAmF;IACnF,6EAA6E;IAC7E,OAAOzB,mBACL0B,yCACAL,WACAC,oBACAC,yBACAC,kBACAC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AAuF;YACvF,qFAAqF;YACrF,uFAAuF;YACvF,iFAAiF;YACjF,MAAMC,oBAAoB;YAE1B,MAAMC,yBAAyB;gBAC7B,2FAA2F;gBAC3F,yFAAyF;gBACzF,+CAA+C;gBAC/CC,eAAe;gBACfC,WAAWpK,gBACPgB,wBAAwBqJ,oBAAoB,GAC5CrJ,wBAAwBsJ,gBAAgB;gBAC5CC,iBAAiB3K;YACnB;YAEA,OAAOV,yBAAyBqG,QAAQ;gBACtC2E;gBACAtF;gBACAqF;gBACAxE,iBAAiB;YACnB;QACF;IACF,CAAC,CAACsC,KAAK;IACP,OAAOC;AACT"}
|
|
@@ -25,6 +25,7 @@ const _serveredge = require("react-server-dom-webpack/server.edge");
|
|
|
25
25
|
const _clientedge = require("react-server-dom-webpack/client.edge");
|
|
26
26
|
const _nodewebstreamshelper = require("../stream-utils/node-web-streams-helper");
|
|
27
27
|
const _encryptionutils = require("./encryption-utils");
|
|
28
|
+
const _workunitasyncstorageexternal = require("./work-unit-async-storage.external");
|
|
28
29
|
const isEdgeRuntime = process.env.NEXT_RUNTIME === 'edge';
|
|
29
30
|
const textEncoder = new TextEncoder();
|
|
30
31
|
const textDecoder = new TextDecoder();
|
|
@@ -50,7 +51,7 @@ async function encodeActionBoundArg(actionId, arg) {
|
|
|
50
51
|
}
|
|
51
52
|
// Get 16 random bytes as iv.
|
|
52
53
|
const randomBytes = new Uint8Array(16);
|
|
53
|
-
crypto.getRandomValues(randomBytes);
|
|
54
|
+
_workunitasyncstorageexternal.workUnitAsyncStorage.exit(()=>crypto.getRandomValues(randomBytes));
|
|
54
55
|
const ivValue = (0, _encryptionutils.arrayBufferToString)(randomBytes.buffer);
|
|
55
56
|
const encrypted = await (0, _encryptionutils.encrypt)(key, randomBytes, textEncoder.encode(actionId + arg));
|
|
56
57
|
return btoa(ivValue + (0, _encryptionutils.arrayBufferToString)(encrypted));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/server/app-render/encryption.ts"],"sourcesContent":["/* eslint-disable import/no-extraneous-dependencies */\nimport 'server-only'\n\n/* eslint-disable import/no-extraneous-dependencies */\nimport { renderToReadableStream } from 'react-server-dom-webpack/server.edge'\n/* eslint-disable import/no-extraneous-dependencies */\nimport { createFromReadableStream } from 'react-server-dom-webpack/client.edge'\n\nimport { streamToString } from '../stream-utils/node-web-streams-helper'\nimport {\n arrayBufferToString,\n decrypt,\n encrypt,\n getActionEncryptionKey,\n getClientReferenceManifestForRsc,\n getServerModuleMap,\n stringToUint8Array,\n} from './encryption-utils'\n\nconst isEdgeRuntime = process.env.NEXT_RUNTIME === 'edge'\n\nconst textEncoder = new TextEncoder()\nconst textDecoder = new TextDecoder()\n\nasync function decodeActionBoundArg(actionId: string, arg: string) {\n const key = await getActionEncryptionKey()\n if (typeof key === 'undefined') {\n throw new Error(\n `Missing encryption key for Server Action. This is a bug in Next.js`\n )\n }\n\n // Get the iv (16 bytes) and the payload from the arg.\n const originalPayload = atob(arg)\n const ivValue = originalPayload.slice(0, 16)\n const payload = originalPayload.slice(16)\n\n const decrypted = textDecoder.decode(\n await decrypt(key, stringToUint8Array(ivValue), stringToUint8Array(payload))\n )\n\n if (!decrypted.startsWith(actionId)) {\n throw new Error('Invalid Server Action payload: failed to decrypt.')\n }\n\n return decrypted.slice(actionId.length)\n}\n\nasync function encodeActionBoundArg(actionId: string, arg: string) {\n const key = await getActionEncryptionKey()\n if (key === undefined) {\n throw new Error(\n `Missing encryption key for Server Action. This is a bug in Next.js`\n )\n }\n\n // Get 16 random bytes as iv.\n const randomBytes = new Uint8Array(16)\n crypto.getRandomValues(randomBytes)\n const ivValue = arrayBufferToString(randomBytes.buffer)\n\n const encrypted = await encrypt(\n key,\n randomBytes,\n textEncoder.encode(actionId + arg)\n )\n\n return btoa(ivValue + arrayBufferToString(encrypted))\n}\n\n// Encrypts the action's bound args into a string.\nexport async function encryptActionBoundArgs(actionId: string, args: any[]) {\n const { clientModules } = getClientReferenceManifestForRsc()\n\n // Using Flight to serialize the args into a string.\n const serialized = await streamToString(\n renderToReadableStream(args, clientModules)\n )\n\n // Encrypt the serialized string with the action id as the salt.\n // Add a prefix to later ensure that the payload is correctly decrypted, similar\n // to a checksum.\n const encrypted = await encodeActionBoundArg(actionId, serialized)\n\n return encrypted\n}\n\n// Decrypts the action's bound args from the encrypted string.\nexport async function decryptActionBoundArgs(\n actionId: string,\n encrypted: Promise<string>\n) {\n const { edgeRscModuleMapping, rscModuleMapping } =\n getClientReferenceManifestForRsc()\n\n // Decrypt the serialized string with the action id as the salt.\n const decrypted = await decodeActionBoundArg(actionId, await encrypted)\n\n // Using Flight to deserialize the args from the string.\n const deserialized = await createFromReadableStream(\n new ReadableStream({\n start(controller) {\n controller.enqueue(textEncoder.encode(decrypted))\n controller.close()\n },\n }),\n {\n serverConsumerManifest: {\n // moduleLoading must be null because we don't want to trigger preloads of ClientReferences\n // to be added to the current execution. Instead, we'll wait for any ClientReference\n // to be emitted which themselves will handle the preloading.\n moduleLoading: null,\n moduleMap: isEdgeRuntime ? edgeRscModuleMapping : rscModuleMapping,\n serverModuleMap: getServerModuleMap(),\n },\n }\n )\n\n return deserialized\n}\n"],"names":["decryptActionBoundArgs","encryptActionBoundArgs","isEdgeRuntime","process","env","NEXT_RUNTIME","textEncoder","TextEncoder","textDecoder","TextDecoder","decodeActionBoundArg","actionId","arg","key","getActionEncryptionKey","Error","originalPayload","atob","ivValue","slice","payload","decrypted","decode","decrypt","stringToUint8Array","startsWith","length","encodeActionBoundArg","undefined","randomBytes","Uint8Array","crypto","getRandomValues","arrayBufferToString","buffer","encrypted","encrypt","encode","btoa","args","clientModules","getClientReferenceManifestForRsc","serialized","streamToString","renderToReadableStream","edgeRscModuleMapping","rscModuleMapping","deserialized","createFromReadableStream","ReadableStream","start","controller","enqueue","close","serverConsumerManifest","moduleLoading","moduleMap","serverModuleMap","getServerModuleMap"],"mappings":"AAAA,oDAAoD;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["../../../src/server/app-render/encryption.ts"],"sourcesContent":["/* eslint-disable import/no-extraneous-dependencies */\nimport 'server-only'\n\n/* eslint-disable import/no-extraneous-dependencies */\nimport { renderToReadableStream } from 'react-server-dom-webpack/server.edge'\n/* eslint-disable import/no-extraneous-dependencies */\nimport { createFromReadableStream } from 'react-server-dom-webpack/client.edge'\n\nimport { streamToString } from '../stream-utils/node-web-streams-helper'\nimport {\n arrayBufferToString,\n decrypt,\n encrypt,\n getActionEncryptionKey,\n getClientReferenceManifestForRsc,\n getServerModuleMap,\n stringToUint8Array,\n} from './encryption-utils'\nimport { workUnitAsyncStorage } from './work-unit-async-storage.external'\n\nconst isEdgeRuntime = process.env.NEXT_RUNTIME === 'edge'\n\nconst textEncoder = new TextEncoder()\nconst textDecoder = new TextDecoder()\n\nasync function decodeActionBoundArg(actionId: string, arg: string) {\n const key = await getActionEncryptionKey()\n if (typeof key === 'undefined') {\n throw new Error(\n `Missing encryption key for Server Action. This is a bug in Next.js`\n )\n }\n\n // Get the iv (16 bytes) and the payload from the arg.\n const originalPayload = atob(arg)\n const ivValue = originalPayload.slice(0, 16)\n const payload = originalPayload.slice(16)\n\n const decrypted = textDecoder.decode(\n await decrypt(key, stringToUint8Array(ivValue), stringToUint8Array(payload))\n )\n\n if (!decrypted.startsWith(actionId)) {\n throw new Error('Invalid Server Action payload: failed to decrypt.')\n }\n\n return decrypted.slice(actionId.length)\n}\n\nasync function encodeActionBoundArg(actionId: string, arg: string) {\n const key = await getActionEncryptionKey()\n if (key === undefined) {\n throw new Error(\n `Missing encryption key for Server Action. This is a bug in Next.js`\n )\n }\n\n // Get 16 random bytes as iv.\n const randomBytes = new Uint8Array(16)\n workUnitAsyncStorage.exit(() => crypto.getRandomValues(randomBytes))\n const ivValue = arrayBufferToString(randomBytes.buffer)\n\n const encrypted = await encrypt(\n key,\n randomBytes,\n textEncoder.encode(actionId + arg)\n )\n\n return btoa(ivValue + arrayBufferToString(encrypted))\n}\n\n// Encrypts the action's bound args into a string.\nexport async function encryptActionBoundArgs(actionId: string, args: any[]) {\n const { clientModules } = getClientReferenceManifestForRsc()\n\n // Using Flight to serialize the args into a string.\n const serialized = await streamToString(\n renderToReadableStream(args, clientModules)\n )\n\n // Encrypt the serialized string with the action id as the salt.\n // Add a prefix to later ensure that the payload is correctly decrypted, similar\n // to a checksum.\n const encrypted = await encodeActionBoundArg(actionId, serialized)\n\n return encrypted\n}\n\n// Decrypts the action's bound args from the encrypted string.\nexport async function decryptActionBoundArgs(\n actionId: string,\n encrypted: Promise<string>\n) {\n const { edgeRscModuleMapping, rscModuleMapping } =\n getClientReferenceManifestForRsc()\n\n // Decrypt the serialized string with the action id as the salt.\n const decrypted = await decodeActionBoundArg(actionId, await encrypted)\n\n // Using Flight to deserialize the args from the string.\n const deserialized = await createFromReadableStream(\n new ReadableStream({\n start(controller) {\n controller.enqueue(textEncoder.encode(decrypted))\n controller.close()\n },\n }),\n {\n serverConsumerManifest: {\n // moduleLoading must be null because we don't want to trigger preloads of ClientReferences\n // to be added to the current execution. Instead, we'll wait for any ClientReference\n // to be emitted which themselves will handle the preloading.\n moduleLoading: null,\n moduleMap: isEdgeRuntime ? edgeRscModuleMapping : rscModuleMapping,\n serverModuleMap: getServerModuleMap(),\n },\n }\n )\n\n return deserialized\n}\n"],"names":["decryptActionBoundArgs","encryptActionBoundArgs","isEdgeRuntime","process","env","NEXT_RUNTIME","textEncoder","TextEncoder","textDecoder","TextDecoder","decodeActionBoundArg","actionId","arg","key","getActionEncryptionKey","Error","originalPayload","atob","ivValue","slice","payload","decrypted","decode","decrypt","stringToUint8Array","startsWith","length","encodeActionBoundArg","undefined","randomBytes","Uint8Array","workUnitAsyncStorage","exit","crypto","getRandomValues","arrayBufferToString","buffer","encrypted","encrypt","encode","btoa","args","clientModules","getClientReferenceManifestForRsc","serialized","streamToString","renderToReadableStream","edgeRscModuleMapping","rscModuleMapping","deserialized","createFromReadableStream","ReadableStream","start","controller","enqueue","close","serverConsumerManifest","moduleLoading","moduleMap","serverModu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,CAAC5B,WAAWC;IAGhC,OAAO4B,KAAKtB,UAAUiB,IAAAA,oCAAmB,EAACE;AAC5C;AAGO,eAAepC,uBAAuBU,QAAgB,EAAE8B,IAAW;IACxE,MAAM,EAAEC,aAAa,EAAE,GAAGC,IAAAA,iDAAgC;IAE1D,oDAAoD;IACpD,MAAMC,aAAa,MAAMC,IAAAA,oCAAc,EACrCC,IAAAA,kCAAsB,EAACL,MAAMC;IAG/B,gEAAgE;IAChE,gFAAgF;IAChF,iBAAiB;IACjB,MAAML,YAAY,MAAMV,qBAAqBhB,UAAUiC;IAEvD,OAAOP;AACT;AAGO,eAAerC,uBACpBW,QAAgB,EAChB0B,SAA0B;IAE1B,MAAM,EAAEU,oBAAoB,EAAEC,gBAAgB,EAAE,GAC9CL,IAAAA,iDAAgC;IAElC,gEAAgE;IAChE,MAAMtB,YAAY,MAAMX,qBAAqBC,UAAU,MAAM0B;IAE7D,wDAAwD;IACxD,MAAMY,eAAe,MAAMC,IAAAA,oCAAwB,EACjD,IAAIC,eAAe;QACjBC,OAAMC,UAAU;YACdA,WAAWC,OAAO,CAAChD,YAAYiC,MAAM,CAAClB;YACtCgC,WAAWE,KAAK;QAClB;IACF,IACA;QACEC,wBAAwB;YACtB,2FAA2F;YAC3F,oFAAoF;YACpF,6DAA6D;YAC7DC,eAAe;YACfC,WAAWxD,gBAAgB6C,uBAAuBC;YAClDW,iBAAiBC,IAAAA,mCAAkB;QACrC;IACF;IAGF,OAAOX;AACT"}
|
package/dist/server/config.js
CHANGED
|
@@ -234,7 +234,7 @@ function assignDefaults(dir, userConfig, silent) {
|
|
|
234
234
|
if (((_result_experimental = result.experimental) == null ? void 0 : _result_experimental.allowDevelopmentBuild) && process.env.NODE_ENV !== 'development') {
|
|
235
235
|
throw new Error(`The experimental.allowDevelopmentBuild option requires NODE_ENV to be explicitly set to 'development'.`);
|
|
236
236
|
}
|
|
237
|
-
if (!((_process_env___NEXT_VERSION = "15.0.4-canary.
|
|
237
|
+
if (!((_process_env___NEXT_VERSION = "15.0.4-canary.3") == null ? void 0 : _process_env___NEXT_VERSION.includes('canary')) && !process.env.__NEXT_TEST_MODE && !process.env.NEXT_PRIVATE_SKIP_CANARY_CHECK) {
|
|
238
238
|
var _result_experimental7, _result_experimental8, _result_experimental_turbo3, _result_experimental9;
|
|
239
239
|
// Prevents usage of certain experimental features outside of canary
|
|
240
240
|
if ((_result_experimental7 = result.experimental) == null ? void 0 : _result_experimental7.ppr) {
|
|
@@ -104,7 +104,7 @@ async function createHotReloaderTurbopack(opts, serverFields, distDir, resetFetc
|
|
|
104
104
|
}
|
|
105
105
|
const hasRewrites = opts.fsChecker.rewrites.afterFiles.length > 0 || opts.fsChecker.rewrites.beforeFiles.length > 0 || opts.fsChecker.rewrites.fallback.length > 0;
|
|
106
106
|
const hotReloaderSpan = (0, _trace.trace)('hot-reloader', undefined, {
|
|
107
|
-
version: "15.0.4-canary.
|
|
107
|
+
version: "15.0.4-canary.3"
|
|
108
108
|
});
|
|
109
109
|
// Ensure the hotReloaderSpan is flushed immediately as it's the parentSpan for all processing
|
|
110
110
|
// of the current `next dev` invocation.
|
|
@@ -260,7 +260,7 @@ class HotReloaderWebpack {
|
|
|
260
260
|
this.previewProps = previewProps;
|
|
261
261
|
this.rewrites = rewrites;
|
|
262
262
|
this.hotReloaderSpan = (0, _trace.trace)('hot-reloader', undefined, {
|
|
263
|
-
version: "15.0.4-canary.
|
|
263
|
+
version: "15.0.4-canary.3"
|
|
264
264
|
});
|
|
265
265
|
// Ensure the hotReloaderSpan is flushed immediately as it's the parentSpan for all processing
|
|
266
266
|
// of the current `next dev` invocation.
|
|
@@ -67,7 +67,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
67
67
|
return newObj;
|
|
68
68
|
}
|
|
69
69
|
function logStartInfo({ networkUrl, appUrl, envInfo, expFeatureInfo, maxExperimentalFeatures = Infinity }) {
|
|
70
|
-
_log.bootstrap(`${(0, _picocolors.bold)((0, _picocolors.purple)(`${_log.prefixes.ready} Next.js ${"15.0.4-canary.
|
|
70
|
+
_log.bootstrap(`${(0, _picocolors.bold)((0, _picocolors.purple)(`${_log.prefixes.ready} Next.js ${"15.0.4-canary.3"}`))}${process.env.TURBOPACK ? ' (Turbopack)' : ''}`);
|
|
71
71
|
if (appUrl) {
|
|
72
72
|
_log.bootstrap(`- Local: ${appUrl}`);
|
|
73
73
|
}
|
|
@@ -108,7 +108,7 @@ async function getRequestHandlers({ dir, port, isDev, onCleanup, server, hostnam
|
|
|
108
108
|
async function startServer(serverOptions) {
|
|
109
109
|
const { dir, isDev, hostname, minimalMode, allowRetry, keepAliveTimeout, selfSignedCertificate } = serverOptions;
|
|
110
110
|
let { port } = serverOptions;
|
|
111
|
-
process.title = `next-server (v${"15.0.4-canary.
|
|
111
|
+
process.title = `next-server (v${"15.0.4-canary.3"})`;
|
|
112
112
|
let handlersReady = ()=>{};
|
|
113
113
|
let handlersError = ()=>{};
|
|
114
114
|
let handlersPromise = new Promise((resolve, reject)=>{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function cache(kind: string, id: string, fn: any): (...args: any[]) => Promise<unknown>;
|
|
1
|
+
export declare function cache(kind: string, id: string, boundArgsLength: number, fn: any): (...args: any[]) => Promise<unknown>;
|
|
@@ -16,6 +16,8 @@ const _cleanasyncsnapshotexternal = require("../app-render/clean-async-snapshot.
|
|
|
16
16
|
const _dynamicrenderingutils = require("../dynamic-rendering-utils");
|
|
17
17
|
const _encryptionutils = require("../app-render/encryption-utils");
|
|
18
18
|
const _default = /*#__PURE__*/ _interop_require_default(require("../lib/cache-handlers/default"));
|
|
19
|
+
const _encryption = require("../app-render/encryption");
|
|
20
|
+
const _invarianterror = require("../../shared/lib/invariant-error");
|
|
19
21
|
function _interop_require_default(obj) {
|
|
20
22
|
return obj && obj.__esModule ? obj : {
|
|
21
23
|
default: obj
|
|
@@ -263,7 +265,7 @@ function createTrackedReadableStream(stream, cacheSignal) {
|
|
|
263
265
|
}
|
|
264
266
|
});
|
|
265
267
|
}
|
|
266
|
-
function cache(kind, id, fn) {
|
|
268
|
+
function cache(kind, id, boundArgsLength, fn) {
|
|
267
269
|
if (!process.env.__NEXT_DYNAMIC_IO) {
|
|
268
270
|
throw new Error('"use cache" is only available with the experimental.dynamicIO config.');
|
|
269
271
|
}
|
|
@@ -313,6 +315,20 @@ function cache(kind, id, fn) {
|
|
|
313
315
|
process.nextTick(()=>controller.abort());
|
|
314
316
|
}
|
|
315
317
|
}
|
|
318
|
+
if (boundArgsLength > 0) {
|
|
319
|
+
if (args.length === 0) {
|
|
320
|
+
throw new _invarianterror.InvariantError(`Expected the "use cache" function ${JSON.stringify(fn.name)} to receive its encrypted bound arguments as the first argument.`);
|
|
321
|
+
}
|
|
322
|
+
const encryptedBoundArgs = args.shift();
|
|
323
|
+
const boundArgs = await (0, _encryption.decryptActionBoundArgs)(id, encryptedBoundArgs);
|
|
324
|
+
if (!Array.isArray(boundArgs)) {
|
|
325
|
+
throw new _invarianterror.InvariantError(`Expected the bound arguments of "use cache" function ${JSON.stringify(fn.name)} to deserialize into an array, got ${typeof boundArgs} instead.`);
|
|
326
|
+
}
|
|
327
|
+
if (boundArgsLength !== boundArgs.length) {
|
|
328
|
+
throw new _invarianterror.InvariantError(`Expected the "use cache" function ${JSON.stringify(fn.name)} to receive ${boundArgsLength} bound arguments, got ${boundArgs.length} instead.`);
|
|
329
|
+
}
|
|
330
|
+
args.unshift(...boundArgs);
|
|
331
|
+
}
|
|
316
332
|
const temporaryReferences = (0, _clientedge.createTemporaryReferenceSet)();
|
|
317
333
|
const encodedArguments = await (0, _clientedge.encodeReply)([
|
|
318
334
|
buildId,
|
|
@@ -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,8CAAk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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","rscModu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,wBAAwBmK,oBAAoB,GAC5CnK,wBAAwBoK,gBAAgB;gBAC5CC,iBAAiBlG,IAAAA,mCAAkB;YACrC;YAEA,OAAOmG,IAAAA,oCAAwB,EAACzF,QAAQ;gBACtCmF;gBACAjG;gBACAgG;gBACA/E,iBAAiB;YACnB;QACF;IACF,CAAC,CAACqC,KAAK;IACP,OAAOC;AACT"}
|
|
@@ -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.
|
|
14
|
+
if (typeof "15.0.4-canary.3" !== 'string') {
|
|
15
15
|
return [];
|
|
16
16
|
}
|
|
17
17
|
const payload = {
|
|
18
|
-
nextVersion: "15.0.4-canary.
|
|
18
|
+
nextVersion: "15.0.4-canary.3",
|
|
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.
|
|
39
|
+
if (typeof "15.0.4-canary.3" !== 'string') {
|
|
40
40
|
return [];
|
|
41
41
|
}
|
|
42
42
|
const { images, i18n } = nextConfig || {};
|
|
43
43
|
const payload = {
|
|
44
|
-
nextVersion: "15.0.4-canary.
|
|
44
|
+
nextVersion: "15.0.4-canary.3",
|
|
45
45
|
nodeVersion: process.version,
|
|
46
46
|
cliCommand: event.cliCommand,
|
|
47
47
|
isSrcDir: event.isSrcDir,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next",
|
|
3
|
-
"version": "15.0.4-canary.
|
|
3
|
+
"version": "15.0.4-canary.3",
|
|
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.
|
|
100
|
+
"@next/env": "15.0.4-canary.3",
|
|
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.
|
|
133
|
-
"@next/swc-darwin-x64": "15.0.4-canary.
|
|
134
|
-
"@next/swc-linux-arm64-gnu": "15.0.4-canary.
|
|
135
|
-
"@next/swc-linux-arm64-musl": "15.0.4-canary.
|
|
136
|
-
"@next/swc-linux-x64-gnu": "15.0.4-canary.
|
|
137
|
-
"@next/swc-linux-x64-musl": "15.0.4-canary.
|
|
138
|
-
"@next/swc-win32-arm64-msvc": "15.0.4-canary.
|
|
139
|
-
"@next/swc-win32-x64-msvc": "15.0.4-canary.
|
|
132
|
+
"@next/swc-darwin-arm64": "15.0.4-canary.3",
|
|
133
|
+
"@next/swc-darwin-x64": "15.0.4-canary.3",
|
|
134
|
+
"@next/swc-linux-arm64-gnu": "15.0.4-canary.3",
|
|
135
|
+
"@next/swc-linux-arm64-musl": "15.0.4-canary.3",
|
|
136
|
+
"@next/swc-linux-x64-gnu": "15.0.4-canary.3",
|
|
137
|
+
"@next/swc-linux-x64-musl": "15.0.4-canary.3",
|
|
138
|
+
"@next/swc-win32-arm64-msvc": "15.0.4-canary.3",
|
|
139
|
+
"@next/swc-win32-x64-msvc": "15.0.4-canary.3"
|
|
140
140
|
},
|
|
141
141
|
"devDependencies": {
|
|
142
142
|
"@ampproject/toolbox-optimizer": "2.8.3",
|
|
@@ -169,11 +169,11 @@
|
|
|
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.
|
|
173
|
-
"@next/polyfill-module": "15.0.4-canary.
|
|
174
|
-
"@next/polyfill-nomodule": "15.0.4-canary.
|
|
175
|
-
"@next/react-refresh-utils": "15.0.4-canary.
|
|
176
|
-
"@next/swc": "15.0.4-canary.
|
|
172
|
+
"@next/font": "15.0.4-canary.3",
|
|
173
|
+
"@next/polyfill-module": "15.0.4-canary.3",
|
|
174
|
+
"@next/polyfill-nomodule": "15.0.4-canary.3",
|
|
175
|
+
"@next/react-refresh-utils": "15.0.4-canary.3",
|
|
176
|
+
"@next/swc": "15.0.4-canary.3",
|
|
177
177
|
"@opentelemetry/api": "1.6.0",
|
|
178
178
|
"@playwright/test": "1.41.2",
|
|
179
179
|
"@swc/core": "1.7.0-nightly-20240714.1",
|