diff --git a/packages/next/src/compiled/react-server-dom-turbopack-experimental/cjs/react-server-dom-turbopack-client.edge.development.js b/packages/next/src/compiled/react-server-dom-turbopack-experimental/cjs/react-server-dom-turbopack-client.edge.development.js index f8565373770b6..d1763a29aeca0 100644 --- a/packages/next/src/compiled/react-server-dom-turbopack-experimental/cjs/react-server-dom-turbopack-client.edge.development.js +++ b/packages/next/src/compiled/react-server-dom-turbopack-experimental/cjs/react-server-dom-turbopack-client.edge.development.js @@ -78,7 +78,20 @@ return promise; } function ignoreReject() {} + const { workUnitAsyncStorage } = require("next/dist/server/app-render/work-unit-async-storage.external"); function preloadModule(metadata) { + const workUnitStore = workUnitAsyncStorage.getStore(); + const cacheSignal = workUnitStore?.type === 'prerender' ? workUnitStore.cacheSignal : undefined; + const promise = _preloadModule(metadata) + + if (promise && cacheSignal) { + cacheSignal.beginRead(); + return promise.finally(() => cacheSignal.endRead()); + } + + return promise + } + function _preloadModule(metadata) { for ( var chunks = metadata[1], promises = [], i = 0; i < chunks.length; diff --git a/packages/next/src/compiled/react-server-dom-turbopack-experimental/cjs/react-server-dom-turbopack-client.edge.production.js b/packages/next/src/compiled/react-server-dom-turbopack-experimental/cjs/react-server-dom-turbopack-client.edge.production.js index d73023322bcb3..fb513fffef522 100644 --- a/packages/next/src/compiled/react-server-dom-turbopack-experimental/cjs/react-server-dom-turbopack-client.edge.production.js +++ b/packages/next/src/compiled/react-server-dom-turbopack-experimental/cjs/react-server-dom-turbopack-client.edge.production.js @@ -68,7 +68,20 @@ function requireAsyncModule(id) { return promise; } function ignoreReject() {} +const { workUnitAsyncStorage } = require("next/dist/server/app-render/work-unit-async-storage.external"); function preloadModule(metadata) { + const workUnitStore = workUnitAsyncStorage.getStore(); + const cacheSignal = workUnitStore?.type === 'prerender' ? workUnitStore.cacheSignal : undefined; + const promise = _preloadModule(metadata) + + if (promise && cacheSignal) { + cacheSignal.beginRead(); + return promise.finally(() => cacheSignal.endRead()); + } + + return promise +} +function _preloadModule(metadata) { for (var chunks = metadata[1], promises = [], i = 0; i < chunks.length; i++) { var chunkFilename = chunks[i], entry = chunkCache.get(chunkFilename); diff --git a/packages/next/src/compiled/react-server-dom-turbopack-experimental/cjs/react-server-dom-turbopack-client.node.development.js b/packages/next/src/compiled/react-server-dom-turbopack-experimental/cjs/react-server-dom-turbopack-client.node.development.js index fb983efefbc99..895a6a705e76a 100644 --- a/packages/next/src/compiled/react-server-dom-turbopack-experimental/cjs/react-server-dom-turbopack-client.node.development.js +++ b/packages/next/src/compiled/react-server-dom-turbopack-experimental/cjs/react-server-dom-turbopack-client.node.development.js @@ -78,7 +78,20 @@ return promise; } function ignoreReject() {} + const { workUnitAsyncStorage } = require("next/dist/server/app-render/work-unit-async-storage.external"); function preloadModule(metadata) { + const workUnitStore = workUnitAsyncStorage.getStore(); + const cacheSignal = workUnitStore?.type === 'prerender' ? workUnitStore.cacheSignal : undefined; + const promise = _preloadModule(metadata) + + if (promise && cacheSignal) { + cacheSignal.beginRead(); + return promise.finally(() => cacheSignal.endRead()); + } + + return promise + } + function _preloadModule(metadata) { for ( var chunks = metadata[1], promises = [], i = 0; i < chunks.length; diff --git a/packages/next/src/compiled/react-server-dom-turbopack-experimental/cjs/react-server-dom-turbopack-client.node.production.js b/packages/next/src/compiled/react-server-dom-turbopack-experimental/cjs/react-server-dom-turbopack-client.node.production.js index 8b881c2fe447e..08054ebf712b9 100644 --- a/packages/next/src/compiled/react-server-dom-turbopack-experimental/cjs/react-server-dom-turbopack-client.node.production.js +++ b/packages/next/src/compiled/react-server-dom-turbopack-experimental/cjs/react-server-dom-turbopack-client.node.production.js @@ -69,7 +69,20 @@ function requireAsyncModule(id) { return promise; } function ignoreReject() {} +const { workUnitAsyncStorage } = require("next/dist/server/app-render/work-unit-async-storage.external"); function preloadModule(metadata) { + const workUnitStore = workUnitAsyncStorage.getStore(); + const cacheSignal = workUnitStore?.type === 'prerender' ? workUnitStore.cacheSignal : undefined; + const promise = _preloadModule(metadata) + + if (promise && cacheSignal) { + cacheSignal.beginRead(); + return promise.finally(() => cacheSignal.endRead()); + } + + return promise +} +function _preloadModule(metadata) { for (var chunks = metadata[1], promises = [], i = 0; i < chunks.length; i++) { var chunkFilename = chunks[i], entry = chunkCache.get(chunkFilename); diff --git a/packages/next/src/compiled/react-server-dom-turbopack-experimental/cjs/react-server-dom-turbopack-server.edge.development.js b/packages/next/src/compiled/react-server-dom-turbopack-experimental/cjs/react-server-dom-turbopack-server.edge.development.js index a70dfb3d5ca19..202934840dbef 100644 --- a/packages/next/src/compiled/react-server-dom-turbopack-experimental/cjs/react-server-dom-turbopack-server.edge.development.js +++ b/packages/next/src/compiled/react-server-dom-turbopack-experimental/cjs/react-server-dom-turbopack-server.edge.development.js @@ -2899,7 +2899,20 @@ return promise; } function ignoreReject() {} + const { workUnitAsyncStorage } = require("next/dist/server/app-render/work-unit-async-storage.external"); function preloadModule(metadata) { + const workUnitStore = workUnitAsyncStorage.getStore(); + const cacheSignal = workUnitStore?.type === 'prerender' ? workUnitStore.cacheSignal : undefined; + const promise = _preloadModule(metadata) + + if (promise && cacheSignal) { + cacheSignal.beginRead(); + return promise.finally(() => cacheSignal.endRead()); + } + + return promise + } + function _preloadModule(metadata) { for ( var chunks = metadata[1], promises = [], i = 0; i < chunks.length; diff --git a/packages/next/src/compiled/react-server-dom-turbopack-experimental/cjs/react-server-dom-turbopack-server.edge.production.js b/packages/next/src/compiled/react-server-dom-turbopack-experimental/cjs/react-server-dom-turbopack-server.edge.production.js index 38ca1e59ee99a..6c0b4092f277e 100644 --- a/packages/next/src/compiled/react-server-dom-turbopack-experimental/cjs/react-server-dom-turbopack-server.edge.production.js +++ b/packages/next/src/compiled/react-server-dom-turbopack-experimental/cjs/react-server-dom-turbopack-server.edge.production.js @@ -2079,7 +2079,20 @@ function requireAsyncModule(id) { return promise; } function ignoreReject() {} +const { workUnitAsyncStorage } = require("next/dist/server/app-render/work-unit-async-storage.external"); function preloadModule(metadata) { + const workUnitStore = workUnitAsyncStorage.getStore(); + const cacheSignal = workUnitStore?.type === 'prerender' ? workUnitStore.cacheSignal : undefined; + const promise = _preloadModule(metadata) + + if (promise && cacheSignal) { + cacheSignal.beginRead(); + return promise.finally(() => cacheSignal.endRead()); + } + + return promise +} +function _preloadModule(metadata) { for (var chunks = metadata[1], promises = [], i = 0; i < chunks.length; i++) { var chunkFilename = chunks[i], entry = chunkCache.get(chunkFilename); diff --git a/packages/next/src/compiled/react-server-dom-turbopack-experimental/cjs/react-server-dom-turbopack-server.node.development.js b/packages/next/src/compiled/react-server-dom-turbopack-experimental/cjs/react-server-dom-turbopack-server.node.development.js index 4226e13330872..7945eb4393c2f 100644 --- a/packages/next/src/compiled/react-server-dom-turbopack-experimental/cjs/react-server-dom-turbopack-server.node.development.js +++ b/packages/next/src/compiled/react-server-dom-turbopack-experimental/cjs/react-server-dom-turbopack-server.node.development.js @@ -2870,7 +2870,20 @@ return promise; } function ignoreReject() {} + const { workUnitAsyncStorage } = require("next/dist/server/app-render/work-unit-async-storage.external"); function preloadModule(metadata) { + const workUnitStore = workUnitAsyncStorage.getStore(); + const cacheSignal = workUnitStore?.type === 'prerender' ? workUnitStore.cacheSignal : undefined; + const promise = _preloadModule(metadata) + + if (promise && cacheSignal) { + cacheSignal.beginRead(); + return promise.finally(() => cacheSignal.endRead()); + } + + return promise + } + function _preloadModule(metadata) { for ( var chunks = metadata[1], promises = [], i = 0; i < chunks.length; diff --git a/packages/next/src/compiled/react-server-dom-turbopack-experimental/cjs/react-server-dom-turbopack-server.node.production.js b/packages/next/src/compiled/react-server-dom-turbopack-experimental/cjs/react-server-dom-turbopack-server.node.production.js index 6c9502db3987b..8b753e5e153ba 100644 --- a/packages/next/src/compiled/react-server-dom-turbopack-experimental/cjs/react-server-dom-turbopack-server.node.production.js +++ b/packages/next/src/compiled/react-server-dom-turbopack-experimental/cjs/react-server-dom-turbopack-server.node.production.js @@ -2100,7 +2100,20 @@ function requireAsyncModule(id) { return promise; } function ignoreReject() {} +const { workUnitAsyncStorage } = require("next/dist/server/app-render/work-unit-async-storage.external"); function preloadModule(metadata) { + const workUnitStore = workUnitAsyncStorage.getStore(); + const cacheSignal = workUnitStore?.type === 'prerender' ? workUnitStore.cacheSignal : undefined; + const promise = _preloadModule(metadata) + + if (promise && cacheSignal) { + cacheSignal.beginRead(); + return promise.finally(() => cacheSignal.endRead()); + } + + return promise +} +function _preloadModule(metadata) { for (var chunks = metadata[1], promises = [], i = 0; i < chunks.length; i++) { var chunkFilename = chunks[i], entry = chunkCache.get(chunkFilename); diff --git a/packages/next/src/compiled/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.edge.development.js b/packages/next/src/compiled/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.edge.development.js index 76f7b8c740a6a..380080a103b29 100644 --- a/packages/next/src/compiled/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.edge.development.js +++ b/packages/next/src/compiled/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.edge.development.js @@ -78,7 +78,20 @@ return promise; } function ignoreReject() {} + const { workUnitAsyncStorage } = require("next/dist/server/app-render/work-unit-async-storage.external"); function preloadModule(metadata) { + const workUnitStore = workUnitAsyncStorage.getStore(); + const cacheSignal = workUnitStore?.type === 'prerender' ? workUnitStore.cacheSignal : undefined; + const promise = _preloadModule(metadata) + + if (promise && cacheSignal) { + cacheSignal.beginRead(); + return promise.finally(() => cacheSignal.endRead()); + } + + return promise + } + function _preloadModule(metadata) { for ( var chunks = metadata[1], promises = [], i = 0; i < chunks.length; diff --git a/packages/next/src/compiled/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.edge.production.js b/packages/next/src/compiled/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.edge.production.js index a5ae8b416d0c5..e6ecef26cf1c7 100644 --- a/packages/next/src/compiled/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.edge.production.js +++ b/packages/next/src/compiled/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.edge.production.js @@ -68,7 +68,20 @@ function requireAsyncModule(id) { return promise; } function ignoreReject() {} +const { workUnitAsyncStorage } = require("next/dist/server/app-render/work-unit-async-storage.external"); function preloadModule(metadata) { + const workUnitStore = workUnitAsyncStorage.getStore(); + const cacheSignal = workUnitStore?.type === 'prerender' ? workUnitStore.cacheSignal : undefined; + const promise = _preloadModule(metadata) + + if (promise && cacheSignal) { + cacheSignal.beginRead(); + return promise.finally(() => cacheSignal.endRead()); + } + + return promise +} +function _preloadModule(metadata) { for (var chunks = metadata[1], promises = [], i = 0; i < chunks.length; i++) { var chunkFilename = chunks[i], entry = chunkCache.get(chunkFilename); diff --git a/packages/next/src/compiled/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.node.development.js b/packages/next/src/compiled/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.node.development.js index 23de4540b346d..8208b012a7f62 100644 --- a/packages/next/src/compiled/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.node.development.js +++ b/packages/next/src/compiled/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.node.development.js @@ -78,7 +78,20 @@ return promise; } function ignoreReject() {} + const { workUnitAsyncStorage } = require("next/dist/server/app-render/work-unit-async-storage.external"); function preloadModule(metadata) { + const workUnitStore = workUnitAsyncStorage.getStore(); + const cacheSignal = workUnitStore?.type === 'prerender' ? workUnitStore.cacheSignal : undefined; + const promise = _preloadModule(metadata) + + if (promise && cacheSignal) { + cacheSignal.beginRead(); + return promise.finally(() => cacheSignal.endRead()); + } + + return promise + } + function _preloadModule(metadata) { for ( var chunks = metadata[1], promises = [], i = 0; i < chunks.length; diff --git a/packages/next/src/compiled/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.node.production.js b/packages/next/src/compiled/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.node.production.js index ecc9caabf05b5..4e4f4c0252e74 100644 --- a/packages/next/src/compiled/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.node.production.js +++ b/packages/next/src/compiled/react-server-dom-turbopack/cjs/react-server-dom-turbopack-client.node.production.js @@ -69,7 +69,20 @@ function requireAsyncModule(id) { return promise; } function ignoreReject() {} +const { workUnitAsyncStorage } = require("next/dist/server/app-render/work-unit-async-storage.external"); function preloadModule(metadata) { + const workUnitStore = workUnitAsyncStorage.getStore(); + const cacheSignal = workUnitStore?.type === 'prerender' ? workUnitStore.cacheSignal : undefined; + const promise = _preloadModule(metadata) + + if (promise && cacheSignal) { + cacheSignal.beginRead(); + return promise.finally(() => cacheSignal.endRead()); + } + + return promise +} +function _preloadModule(metadata) { for (var chunks = metadata[1], promises = [], i = 0; i < chunks.length; i++) { var chunkFilename = chunks[i], entry = chunkCache.get(chunkFilename); diff --git a/packages/next/src/compiled/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.edge.development.js b/packages/next/src/compiled/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.edge.development.js index 5d06b712b347a..4107f1e3bf95c 100644 --- a/packages/next/src/compiled/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.edge.development.js +++ b/packages/next/src/compiled/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.edge.development.js @@ -2493,7 +2493,20 @@ return promise; } function ignoreReject() {} + const { workUnitAsyncStorage } = require("next/dist/server/app-render/work-unit-async-storage.external"); function preloadModule(metadata) { + const workUnitStore = workUnitAsyncStorage.getStore(); + const cacheSignal = workUnitStore?.type === 'prerender' ? workUnitStore.cacheSignal : undefined; + const promise = _preloadModule(metadata) + + if (promise && cacheSignal) { + cacheSignal.beginRead(); + return promise.finally(() => cacheSignal.endRead()); + } + + return promise + } + function _preloadModule(metadata) { for ( var chunks = metadata[1], promises = [], i = 0; i < chunks.length; diff --git a/packages/next/src/compiled/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.edge.production.js b/packages/next/src/compiled/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.edge.production.js index 30a7cbecc9182..21590418d9230 100644 --- a/packages/next/src/compiled/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.edge.production.js +++ b/packages/next/src/compiled/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.edge.production.js @@ -1953,7 +1953,20 @@ function requireAsyncModule(id) { return promise; } function ignoreReject() {} +const { workUnitAsyncStorage } = require("next/dist/server/app-render/work-unit-async-storage.external"); function preloadModule(metadata) { + const workUnitStore = workUnitAsyncStorage.getStore(); + const cacheSignal = workUnitStore?.type === 'prerender' ? workUnitStore.cacheSignal : undefined; + const promise = _preloadModule(metadata) + + if (promise && cacheSignal) { + cacheSignal.beginRead(); + return promise.finally(() => cacheSignal.endRead()); + } + + return promise +} +function _preloadModule(metadata) { for (var chunks = metadata[1], promises = [], i = 0; i < chunks.length; i++) { var chunkFilename = chunks[i], entry = chunkCache.get(chunkFilename); diff --git a/packages/next/src/compiled/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.development.js b/packages/next/src/compiled/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.development.js index 11f83524bd52d..43c0ece8aa04b 100644 --- a/packages/next/src/compiled/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.development.js +++ b/packages/next/src/compiled/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.development.js @@ -2491,7 +2491,20 @@ return promise; } function ignoreReject() {} + const { workUnitAsyncStorage } = require("next/dist/server/app-render/work-unit-async-storage.external"); function preloadModule(metadata) { + const workUnitStore = workUnitAsyncStorage.getStore(); + const cacheSignal = workUnitStore?.type === 'prerender' ? workUnitStore.cacheSignal : undefined; + const promise = _preloadModule(metadata) + + if (promise && cacheSignal) { + cacheSignal.beginRead(); + return promise.finally(() => cacheSignal.endRead()); + } + + return promise + } + function _preloadModule(metadata) { for ( var chunks = metadata[1], promises = [], i = 0; i < chunks.length; diff --git a/packages/next/src/compiled/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.production.js b/packages/next/src/compiled/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.production.js index 3e6e6874d2176..16925d7240325 100644 --- a/packages/next/src/compiled/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.production.js +++ b/packages/next/src/compiled/react-server-dom-turbopack/cjs/react-server-dom-turbopack-server.node.production.js @@ -1978,7 +1978,20 @@ function requireAsyncModule(id) { return promise; } function ignoreReject() {} +const { workUnitAsyncStorage } = require("next/dist/server/app-render/work-unit-async-storage.external"); function preloadModule(metadata) { + const workUnitStore = workUnitAsyncStorage.getStore(); + const cacheSignal = workUnitStore?.type === 'prerender' ? workUnitStore.cacheSignal : undefined; + const promise = _preloadModule(metadata) + + if (promise && cacheSignal) { + cacheSignal.beginRead(); + return promise.finally(() => cacheSignal.endRead()); + } + + return promise +} +function _preloadModule(metadata) { for (var chunks = metadata[1], promises = [], i = 0; i < chunks.length; i++) { var chunkFilename = chunks[i], entry = chunkCache.get(chunkFilename); diff --git a/packages/next/src/compiled/react-server-dom-webpack-experimental/cjs/react-server-dom-webpack-client.edge.development.js b/packages/next/src/compiled/react-server-dom-webpack-experimental/cjs/react-server-dom-webpack-client.edge.development.js index 1275009b9f361..83d294dbec8f3 100644 --- a/packages/next/src/compiled/react-server-dom-webpack-experimental/cjs/react-server-dom-webpack-client.edge.development.js +++ b/packages/next/src/compiled/react-server-dom-webpack-experimental/cjs/react-server-dom-webpack-client.edge.development.js @@ -80,7 +80,20 @@ return promise; } function ignoreReject() {} + const { workUnitAsyncStorage } = require("next/dist/server/app-render/work-unit-async-storage.external"); function preloadModule(metadata) { + const workUnitStore = workUnitAsyncStorage.getStore(); + const cacheSignal = workUnitStore?.type === 'prerender' ? workUnitStore.cacheSignal : undefined; + const promise = _preloadModule(metadata) + + if (promise && cacheSignal) { + cacheSignal.beginRead(); + return promise.finally(() => cacheSignal.endRead()); + } + + return promise + } + function _preloadModule(metadata) { for ( var chunks = metadata[1], promises = [], i = 0; i < chunks.length; diff --git a/packages/next/src/compiled/react-server-dom-webpack-experimental/cjs/react-server-dom-webpack-client.edge.production.js b/packages/next/src/compiled/react-server-dom-webpack-experimental/cjs/react-server-dom-webpack-client.edge.production.js index 88970d7497229..abe74023a47ec 100644 --- a/packages/next/src/compiled/react-server-dom-webpack-experimental/cjs/react-server-dom-webpack-client.edge.production.js +++ b/packages/next/src/compiled/react-server-dom-webpack-experimental/cjs/react-server-dom-webpack-client.edge.production.js @@ -70,7 +70,20 @@ function requireAsyncModule(id) { return promise; } function ignoreReject() {} +const { workUnitAsyncStorage } = require("next/dist/server/app-render/work-unit-async-storage.external"); function preloadModule(metadata) { + const workUnitStore = workUnitAsyncStorage.getStore(); + const cacheSignal = workUnitStore?.type === 'prerender' ? workUnitStore.cacheSignal : undefined; + const promise = _preloadModule(metadata) + + if (promise && cacheSignal) { + cacheSignal.beginRead(); + return promise.finally(() => cacheSignal.endRead()); + } + + return promise +} +function _preloadModule(metadata) { for (var chunks = metadata[1], promises = [], i = 0; i < chunks.length; ) { var chunkId = chunks[i++]; chunks[i++]; diff --git a/packages/next/src/compiled/react-server-dom-webpack-experimental/cjs/react-server-dom-webpack-client.node.development.js b/packages/next/src/compiled/react-server-dom-webpack-experimental/cjs/react-server-dom-webpack-client.node.development.js index 575a7e7940c8a..01f9bbaf17fca 100644 --- a/packages/next/src/compiled/react-server-dom-webpack-experimental/cjs/react-server-dom-webpack-client.node.development.js +++ b/packages/next/src/compiled/react-server-dom-webpack-experimental/cjs/react-server-dom-webpack-client.node.development.js @@ -80,7 +80,20 @@ return promise; } function ignoreReject() {} + const { workUnitAsyncStorage } = require("next/dist/server/app-render/work-unit-async-storage.external"); function preloadModule(metadata) { + const workUnitStore = workUnitAsyncStorage.getStore(); + const cacheSignal = workUnitStore?.type === 'prerender' ? workUnitStore.cacheSignal : undefined; + const promise = _preloadModule(metadata) + + if (promise && cacheSignal) { + cacheSignal.beginRead(); + return promise.finally(() => cacheSignal.endRead()); + } + + return promise + } + function _preloadModule(metadata) { for ( var chunks = metadata[1], promises = [], i = 0; i < chunks.length; diff --git a/packages/next/src/compiled/react-server-dom-webpack-experimental/cjs/react-server-dom-webpack-client.node.production.js b/packages/next/src/compiled/react-server-dom-webpack-experimental/cjs/react-server-dom-webpack-client.node.production.js index a655f1255ee6a..cb10957cbe187 100644 --- a/packages/next/src/compiled/react-server-dom-webpack-experimental/cjs/react-server-dom-webpack-client.node.production.js +++ b/packages/next/src/compiled/react-server-dom-webpack-experimental/cjs/react-server-dom-webpack-client.node.production.js @@ -71,7 +71,20 @@ function requireAsyncModule(id) { return promise; } function ignoreReject() {} +const { workUnitAsyncStorage } = require("next/dist/server/app-render/work-unit-async-storage.external"); function preloadModule(metadata) { + const workUnitStore = workUnitAsyncStorage.getStore(); + const cacheSignal = workUnitStore?.type === 'prerender' ? workUnitStore.cacheSignal : undefined; + const promise = _preloadModule(metadata) + + if (promise && cacheSignal) { + cacheSignal.beginRead(); + return promise.finally(() => cacheSignal.endRead()); + } + + return promise +} +function _preloadModule(metadata) { for (var chunks = metadata[1], promises = [], i = 0; i < chunks.length; ) { var chunkId = chunks[i++]; chunks[i++]; diff --git a/packages/next/src/compiled/react-server-dom-webpack-experimental/cjs/react-server-dom-webpack-client.node.unbundled.development.js b/packages/next/src/compiled/react-server-dom-webpack-experimental/cjs/react-server-dom-webpack-client.node.unbundled.development.js index 5a679a3242644..6bce0bf66732a 100644 --- a/packages/next/src/compiled/react-server-dom-webpack-experimental/cjs/react-server-dom-webpack-client.node.unbundled.development.js +++ b/packages/next/src/compiled/react-server-dom-webpack-experimental/cjs/react-server-dom-webpack-client.node.unbundled.development.js @@ -48,7 +48,20 @@ id = id.slice(idx + 1); return { specifier: bundlerConfig, name: id }; } + const { workUnitAsyncStorage } = require("next/dist/server/app-render/work-unit-async-storage.external"); function preloadModule(metadata) { + const workUnitStore = workUnitAsyncStorage.getStore(); + const cacheSignal = workUnitStore?.type === 'prerender' ? workUnitStore.cacheSignal : undefined; + const promise = _preloadModule(metadata) + + if (promise && cacheSignal) { + cacheSignal.beginRead(); + return promise.finally(() => cacheSignal.endRead()); + } + + return promise + } + function _preloadModule(metadata) { var existingPromise = asyncModuleCache.get(metadata.specifier); if (existingPromise) return "fulfilled" === existingPromise.status ? null : existingPromise; diff --git a/packages/next/src/compiled/react-server-dom-webpack-experimental/cjs/react-server-dom-webpack-client.node.unbundled.production.js b/packages/next/src/compiled/react-server-dom-webpack-experimental/cjs/react-server-dom-webpack-client.node.unbundled.production.js index 397f1569b787c..ff8c33c406d7b 100644 --- a/packages/next/src/compiled/react-server-dom-webpack-experimental/cjs/react-server-dom-webpack-client.node.unbundled.production.js +++ b/packages/next/src/compiled/react-server-dom-webpack-experimental/cjs/react-server-dom-webpack-client.node.unbundled.production.js @@ -39,7 +39,20 @@ function resolveServerReference(bundlerConfig, id) { return { specifier: bundlerConfig, name: id }; } var asyncModuleCache = new Map(); +const { workUnitAsyncStorage } = require("next/dist/server/app-render/work-unit-async-storage.external"); function preloadModule(metadata) { + const workUnitStore = workUnitAsyncStorage.getStore(); + const cacheSignal = workUnitStore?.type === 'prerender' ? workUnitStore.cacheSignal : undefined; + const promise = _preloadModule(metadata) + + if (promise && cacheSignal) { + cacheSignal.beginRead(); + return promise.finally(() => cacheSignal.endRead()); + } + + return promise +} +function _preloadModule(metadata) { var existingPromise = asyncModuleCache.get(metadata.specifier); if (existingPromise) return "fulfilled" === existingPromise.status ? null : existingPromise; diff --git a/packages/next/src/compiled/react-server-dom-webpack-experimental/cjs/react-server-dom-webpack-server.edge.development.js b/packages/next/src/compiled/react-server-dom-webpack-experimental/cjs/react-server-dom-webpack-server.edge.development.js index bdf3ae11cd5eb..4f772b21cd1e0 100644 --- a/packages/next/src/compiled/react-server-dom-webpack-experimental/cjs/react-server-dom-webpack-server.edge.development.js +++ b/packages/next/src/compiled/react-server-dom-webpack-experimental/cjs/react-server-dom-webpack-server.edge.development.js @@ -2901,7 +2901,20 @@ return promise; } function ignoreReject() {} + const { workUnitAsyncStorage } = require("next/dist/server/app-render/work-unit-async-storage.external"); function preloadModule(metadata) { + const workUnitStore = workUnitAsyncStorage.getStore(); + const cacheSignal = workUnitStore?.type === 'prerender' ? workUnitStore.cacheSignal : undefined; + const promise = _preloadModule(metadata) + + if (promise && cacheSignal) { + cacheSignal.beginRead(); + return promise.finally(() => cacheSignal.endRead()); + } + + return promise + } + function _preloadModule(metadata) { for ( var chunks = metadata[1], promises = [], i = 0; i < chunks.length; diff --git a/packages/next/src/compiled/react-server-dom-webpack-experimental/cjs/react-server-dom-webpack-server.edge.production.js b/packages/next/src/compiled/react-server-dom-webpack-experimental/cjs/react-server-dom-webpack-server.edge.production.js index 838ffb9b64c08..7a8c128b551d9 100644 --- a/packages/next/src/compiled/react-server-dom-webpack-experimental/cjs/react-server-dom-webpack-server.edge.production.js +++ b/packages/next/src/compiled/react-server-dom-webpack-experimental/cjs/react-server-dom-webpack-server.edge.production.js @@ -2081,7 +2081,20 @@ function requireAsyncModule(id) { return promise; } function ignoreReject() {} +const { workUnitAsyncStorage } = require("next/dist/server/app-render/work-unit-async-storage.external"); function preloadModule(metadata) { + const workUnitStore = workUnitAsyncStorage.getStore(); + const cacheSignal = workUnitStore?.type === 'prerender' ? workUnitStore.cacheSignal : undefined; + const promise = _preloadModule(metadata) + + if (promise && cacheSignal) { + cacheSignal.beginRead(); + return promise.finally(() => cacheSignal.endRead()); + } + + return promise +} +function _preloadModule(metadata) { for (var chunks = metadata[1], promises = [], i = 0; i < chunks.length; ) { var chunkId = chunks[i++]; chunks[i++]; diff --git a/packages/next/src/compiled/react-server-dom-webpack-experimental/cjs/react-server-dom-webpack-server.node.development.js b/packages/next/src/compiled/react-server-dom-webpack-experimental/cjs/react-server-dom-webpack-server.node.development.js index df7fb038df8f7..83685d8c9d2f6 100644 --- a/packages/next/src/compiled/react-server-dom-webpack-experimental/cjs/react-server-dom-webpack-server.node.development.js +++ b/packages/next/src/compiled/react-server-dom-webpack-experimental/cjs/react-server-dom-webpack-server.node.development.js @@ -2872,7 +2872,20 @@ return promise; } function ignoreReject() {} + const { workUnitAsyncStorage } = require("next/dist/server/app-render/work-unit-async-storage.external"); function preloadModule(metadata) { + const workUnitStore = workUnitAsyncStorage.getStore(); + const cacheSignal = workUnitStore?.type === 'prerender' ? workUnitStore.cacheSignal : undefined; + const promise = _preloadModule(metadata) + + if (promise && cacheSignal) { + cacheSignal.beginRead(); + return promise.finally(() => cacheSignal.endRead()); + } + + return promise + } + function _preloadModule(metadata) { for ( var chunks = metadata[1], promises = [], i = 0; i < chunks.length; diff --git a/packages/next/src/compiled/react-server-dom-webpack-experimental/cjs/react-server-dom-webpack-server.node.production.js b/packages/next/src/compiled/react-server-dom-webpack-experimental/cjs/react-server-dom-webpack-server.node.production.js index 226203d5838a4..9b5303ef27406 100644 --- a/packages/next/src/compiled/react-server-dom-webpack-experimental/cjs/react-server-dom-webpack-server.node.production.js +++ b/packages/next/src/compiled/react-server-dom-webpack-experimental/cjs/react-server-dom-webpack-server.node.production.js @@ -2102,7 +2102,20 @@ function requireAsyncModule(id) { return promise; } function ignoreReject() {} +const { workUnitAsyncStorage } = require("next/dist/server/app-render/work-unit-async-storage.external"); function preloadModule(metadata) { + const workUnitStore = workUnitAsyncStorage.getStore(); + const cacheSignal = workUnitStore?.type === 'prerender' ? workUnitStore.cacheSignal : undefined; + const promise = _preloadModule(metadata) + + if (promise && cacheSignal) { + cacheSignal.beginRead(); + return promise.finally(() => cacheSignal.endRead()); + } + + return promise +} +function _preloadModule(metadata) { for (var chunks = metadata[1], promises = [], i = 0; i < chunks.length; ) { var chunkId = chunks[i++]; chunks[i++]; diff --git a/packages/next/src/compiled/react-server-dom-webpack-experimental/cjs/react-server-dom-webpack-server.node.unbundled.development.js b/packages/next/src/compiled/react-server-dom-webpack-experimental/cjs/react-server-dom-webpack-server.node.unbundled.development.js index c8e48c6186887..dbb7c1f4ef6f5 100644 --- a/packages/next/src/compiled/react-server-dom-webpack-experimental/cjs/react-server-dom-webpack-server.node.unbundled.development.js +++ b/packages/next/src/compiled/react-server-dom-webpack-experimental/cjs/react-server-dom-webpack-server.node.unbundled.development.js @@ -2841,7 +2841,20 @@ id = id.slice(idx + 1); return { specifier: bundlerConfig, name: id }; } + const { workUnitAsyncStorage } = require("next/dist/server/app-render/work-unit-async-storage.external"); function preloadModule(metadata) { + const workUnitStore = workUnitAsyncStorage.getStore(); + const cacheSignal = workUnitStore?.type === 'prerender' ? workUnitStore.cacheSignal : undefined; + const promise = _preloadModule(metadata) + + if (promise && cacheSignal) { + cacheSignal.beginRead(); + return promise.finally(() => cacheSignal.endRead()); + } + + return promise + } + function _preloadModule(metadata) { var existingPromise = asyncModuleCache.get(metadata.specifier); if (existingPromise) return "fulfilled" === existingPromise.status ? null : existingPromise; diff --git a/packages/next/src/compiled/react-server-dom-webpack-experimental/cjs/react-server-dom-webpack-server.node.unbundled.production.js b/packages/next/src/compiled/react-server-dom-webpack-experimental/cjs/react-server-dom-webpack-server.node.unbundled.production.js index 4edc835feecdb..1d2ae53c43324 100644 --- a/packages/next/src/compiled/react-server-dom-webpack-experimental/cjs/react-server-dom-webpack-server.node.unbundled.production.js +++ b/packages/next/src/compiled/react-server-dom-webpack-experimental/cjs/react-server-dom-webpack-server.node.unbundled.production.js @@ -2071,7 +2071,20 @@ function resolveServerReference(bundlerConfig, id) { return { specifier: bundlerConfig, name: id }; } var asyncModuleCache = new Map(); +const { workUnitAsyncStorage } = require("next/dist/server/app-render/work-unit-async-storage.external"); function preloadModule(metadata) { + const workUnitStore = workUnitAsyncStorage.getStore(); + const cacheSignal = workUnitStore?.type === 'prerender' ? workUnitStore.cacheSignal : undefined; + const promise = _preloadModule(metadata) + + if (promise && cacheSignal) { + cacheSignal.beginRead(); + return promise.finally(() => cacheSignal.endRead()); + } + + return promise +} +function _preloadModule(metadata) { var existingPromise = asyncModuleCache.get(metadata.specifier); if (existingPromise) return "fulfilled" === existingPromise.status ? null : existingPromise; diff --git a/packages/next/src/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.development.js b/packages/next/src/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.development.js index 392c9302d68d4..e08794ab5d236 100644 --- a/packages/next/src/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.development.js +++ b/packages/next/src/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.development.js @@ -80,7 +80,20 @@ return promise; } function ignoreReject() {} + const { workUnitAsyncStorage } = require("next/dist/server/app-render/work-unit-async-storage.external"); function preloadModule(metadata) { + const workUnitStore = workUnitAsyncStorage.getStore(); + const cacheSignal = workUnitStore?.type === 'prerender' ? workUnitStore.cacheSignal : undefined; + const promise = _preloadModule(metadata) + + if (promise && cacheSignal) { + cacheSignal.beginRead(); + return promise.finally(() => cacheSignal.endRead()); + } + + return promise + } + function _preloadModule(metadata) { for ( var chunks = metadata[1], promises = [], i = 0; i < chunks.length; diff --git a/packages/next/src/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.production.js b/packages/next/src/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.production.js index dcdde78c50090..ee3b9a6af80c5 100644 --- a/packages/next/src/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.production.js +++ b/packages/next/src/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.production.js @@ -70,7 +70,20 @@ function requireAsyncModule(id) { return promise; } function ignoreReject() {} +const { workUnitAsyncStorage } = require("next/dist/server/app-render/work-unit-async-storage.external"); function preloadModule(metadata) { + const workUnitStore = workUnitAsyncStorage.getStore(); + const cacheSignal = workUnitStore?.type === 'prerender' ? workUnitStore.cacheSignal : undefined; + const promise = _preloadModule(metadata) + + if (promise && cacheSignal) { + cacheSignal.beginRead(); + return promise.finally(() => cacheSignal.endRead()); + } + + return promise +} +function _preloadModule(metadata) { for (var chunks = metadata[1], promises = [], i = 0; i < chunks.length; ) { var chunkId = chunks[i++]; chunks[i++]; diff --git a/packages/next/src/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.development.js b/packages/next/src/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.development.js index c24897fa972c0..152d1f16fa924 100644 --- a/packages/next/src/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.development.js +++ b/packages/next/src/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.development.js @@ -80,7 +80,20 @@ return promise; } function ignoreReject() {} + const { workUnitAsyncStorage } = require("next/dist/server/app-render/work-unit-async-storage.external"); function preloadModule(metadata) { + const workUnitStore = workUnitAsyncStorage.getStore(); + const cacheSignal = workUnitStore?.type === 'prerender' ? workUnitStore.cacheSignal : undefined; + const promise = _preloadModule(metadata) + + if (promise && cacheSignal) { + cacheSignal.beginRead(); + return promise.finally(() => cacheSignal.endRead()); + } + + return promise + } + function _preloadModule(metadata) { for ( var chunks = metadata[1], promises = [], i = 0; i < chunks.length; diff --git a/packages/next/src/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.production.js b/packages/next/src/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.production.js index a98b699401cb9..86eaa04b501bb 100644 --- a/packages/next/src/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.production.js +++ b/packages/next/src/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.production.js @@ -71,7 +71,20 @@ function requireAsyncModule(id) { return promise; } function ignoreReject() {} +const { workUnitAsyncStorage } = require("next/dist/server/app-render/work-unit-async-storage.external"); function preloadModule(metadata) { + const workUnitStore = workUnitAsyncStorage.getStore(); + const cacheSignal = workUnitStore?.type === 'prerender' ? workUnitStore.cacheSignal : undefined; + const promise = _preloadModule(metadata) + + if (promise && cacheSignal) { + cacheSignal.beginRead(); + return promise.finally(() => cacheSignal.endRead()); + } + + return promise +} +function _preloadModule(metadata) { for (var chunks = metadata[1], promises = [], i = 0; i < chunks.length; ) { var chunkId = chunks[i++]; chunks[i++]; diff --git a/packages/next/src/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.development.js b/packages/next/src/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.development.js index 95c7832e6b618..a8818bdc2c690 100644 --- a/packages/next/src/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.development.js +++ b/packages/next/src/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.development.js @@ -48,7 +48,20 @@ id = id.slice(idx + 1); return { specifier: bundlerConfig, name: id }; } + const { workUnitAsyncStorage } = require("next/dist/server/app-render/work-unit-async-storage.external"); function preloadModule(metadata) { + const workUnitStore = workUnitAsyncStorage.getStore(); + const cacheSignal = workUnitStore?.type === 'prerender' ? workUnitStore.cacheSignal : undefined; + const promise = _preloadModule(metadata) + + if (promise && cacheSignal) { + cacheSignal.beginRead(); + return promise.finally(() => cacheSignal.endRead()); + } + + return promise + } + function _preloadModule(metadata) { var existingPromise = asyncModuleCache.get(metadata.specifier); if (existingPromise) return "fulfilled" === existingPromise.status ? null : existingPromise; diff --git a/packages/next/src/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.production.js b/packages/next/src/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.production.js index ff2b094a8d270..c7e1baee88608 100644 --- a/packages/next/src/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.production.js +++ b/packages/next/src/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.production.js @@ -39,7 +39,20 @@ function resolveServerReference(bundlerConfig, id) { return { specifier: bundlerConfig, name: id }; } var asyncModuleCache = new Map(); +const { workUnitAsyncStorage } = require("next/dist/server/app-render/work-unit-async-storage.external"); function preloadModule(metadata) { + const workUnitStore = workUnitAsyncStorage.getStore(); + const cacheSignal = workUnitStore?.type === 'prerender' ? workUnitStore.cacheSignal : undefined; + const promise = _preloadModule(metadata) + + if (promise && cacheSignal) { + cacheSignal.beginRead(); + return promise.finally(() => cacheSignal.endRead()); + } + + return promise +} +function _preloadModule(metadata) { var existingPromise = asyncModuleCache.get(metadata.specifier); if (existingPromise) return "fulfilled" === existingPromise.status ? null : existingPromise; diff --git a/packages/next/src/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.development.js b/packages/next/src/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.development.js index af07d05872f6d..7082f99e022d9 100644 --- a/packages/next/src/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.development.js +++ b/packages/next/src/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.development.js @@ -2495,7 +2495,20 @@ return promise; } function ignoreReject() {} + const { workUnitAsyncStorage } = require("next/dist/server/app-render/work-unit-async-storage.external"); function preloadModule(metadata) { + const workUnitStore = workUnitAsyncStorage.getStore(); + const cacheSignal = workUnitStore?.type === 'prerender' ? workUnitStore.cacheSignal : undefined; + const promise = _preloadModule(metadata) + + if (promise && cacheSignal) { + cacheSignal.beginRead(); + return promise.finally(() => cacheSignal.endRead()); + } + + return promise + } + function _preloadModule(metadata) { for ( var chunks = metadata[1], promises = [], i = 0; i < chunks.length; diff --git a/packages/next/src/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.production.js b/packages/next/src/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.production.js index 591f7514fec5b..c46a5db576f2e 100644 --- a/packages/next/src/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.production.js +++ b/packages/next/src/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-server.edge.production.js @@ -1955,7 +1955,20 @@ function requireAsyncModule(id) { return promise; } function ignoreReject() {} +const { workUnitAsyncStorage } = require("next/dist/server/app-render/work-unit-async-storage.external"); function preloadModule(metadata) { + const workUnitStore = workUnitAsyncStorage.getStore(); + const cacheSignal = workUnitStore?.type === 'prerender' ? workUnitStore.cacheSignal : undefined; + const promise = _preloadModule(metadata) + + if (promise && cacheSignal) { + cacheSignal.beginRead(); + return promise.finally(() => cacheSignal.endRead()); + } + + return promise +} +function _preloadModule(metadata) { for (var chunks = metadata[1], promises = [], i = 0; i < chunks.length; ) { var chunkId = chunks[i++]; chunks[i++]; diff --git a/packages/next/src/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.development.js b/packages/next/src/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.development.js index c36ffb94c97cb..3ae523f0ad39f 100644 --- a/packages/next/src/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.development.js +++ b/packages/next/src/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.development.js @@ -2493,7 +2493,20 @@ return promise; } function ignoreReject() {} + const { workUnitAsyncStorage } = require("next/dist/server/app-render/work-unit-async-storage.external"); function preloadModule(metadata) { + const workUnitStore = workUnitAsyncStorage.getStore(); + const cacheSignal = workUnitStore?.type === 'prerender' ? workUnitStore.cacheSignal : undefined; + const promise = _preloadModule(metadata) + + if (promise && cacheSignal) { + cacheSignal.beginRead(); + return promise.finally(() => cacheSignal.endRead()); + } + + return promise + } + function _preloadModule(metadata) { for ( var chunks = metadata[1], promises = [], i = 0; i < chunks.length; diff --git a/packages/next/src/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.production.js b/packages/next/src/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.production.js index 55aecba15b25a..4d0bf94efff8f 100644 --- a/packages/next/src/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.production.js +++ b/packages/next/src/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.production.js @@ -1980,7 +1980,20 @@ function requireAsyncModule(id) { return promise; } function ignoreReject() {} +const { workUnitAsyncStorage } = require("next/dist/server/app-render/work-unit-async-storage.external"); function preloadModule(metadata) { + const workUnitStore = workUnitAsyncStorage.getStore(); + const cacheSignal = workUnitStore?.type === 'prerender' ? workUnitStore.cacheSignal : undefined; + const promise = _preloadModule(metadata) + + if (promise && cacheSignal) { + cacheSignal.beginRead(); + return promise.finally(() => cacheSignal.endRead()); + } + + return promise +} +function _preloadModule(metadata) { for (var chunks = metadata[1], promises = [], i = 0; i < chunks.length; ) { var chunkId = chunks[i++]; chunks[i++]; diff --git a/packages/next/src/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.development.js b/packages/next/src/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.development.js index d05cceacd06bd..934b74f6d056f 100644 --- a/packages/next/src/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.development.js +++ b/packages/next/src/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.development.js @@ -2462,7 +2462,20 @@ id = id.slice(idx + 1); return { specifier: bundlerConfig, name: id }; } + const { workUnitAsyncStorage } = require("next/dist/server/app-render/work-unit-async-storage.external"); function preloadModule(metadata) { + const workUnitStore = workUnitAsyncStorage.getStore(); + const cacheSignal = workUnitStore?.type === 'prerender' ? workUnitStore.cacheSignal : undefined; + const promise = _preloadModule(metadata) + + if (promise && cacheSignal) { + cacheSignal.beginRead(); + return promise.finally(() => cacheSignal.endRead()); + } + + return promise + } + function _preloadModule(metadata) { var existingPromise = asyncModuleCache.get(metadata.specifier); if (existingPromise) return "fulfilled" === existingPromise.status ? null : existingPromise; diff --git a/packages/next/src/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.production.js b/packages/next/src/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.production.js index 9dd98c525f7e2..6835193f2e3d0 100644 --- a/packages/next/src/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.production.js +++ b/packages/next/src/compiled/react-server-dom-webpack/cjs/react-server-dom-webpack-server.node.unbundled.production.js @@ -1949,7 +1949,20 @@ function resolveServerReference(bundlerConfig, id) { return { specifier: bundlerConfig, name: id }; } var asyncModuleCache = new Map(); +const { workUnitAsyncStorage } = require("next/dist/server/app-render/work-unit-async-storage.external"); function preloadModule(metadata) { + const workUnitStore = workUnitAsyncStorage.getStore(); + const cacheSignal = workUnitStore?.type === 'prerender' ? workUnitStore.cacheSignal : undefined; + const promise = _preloadModule(metadata) + + if (promise && cacheSignal) { + cacheSignal.beginRead(); + return promise.finally(() => cacheSignal.endRead()); + } + + return promise +} +function _preloadModule(metadata) { var existingPromise = asyncModuleCache.get(metadata.specifier); if (existingPromise) return "fulfilled" === existingPromise.status ? null : existingPromise; diff --git a/packages/next/src/server/app-render/app-render-prerender-utils.ts b/packages/next/src/server/app-render/app-render-prerender-utils.ts index 3a8f1895949bf..c321c9757e376 100644 --- a/packages/next/src/server/app-render/app-render-prerender-utils.ts +++ b/packages/next/src/server/app-render/app-render-prerender-utils.ts @@ -7,7 +7,7 @@ import { isPrerenderInterruptedError } from './dynamic-rendering' */ export function prerenderAndAbortInSequentialTasks( prerender: () => Promise, - abort: () => void + abort: () => Promise ): Promise { if (process.env.NEXT_RUNTIME === 'edge') { throw new InvariantError( @@ -26,7 +26,8 @@ export function prerenderAndAbortInSequentialTasks( }) setImmediate(() => { abort() - resolve(pendingResult) + .then(() => resolve(pendingResult)) + .catch(() => {}) }) }) } diff --git a/packages/next/src/server/app-render/app-render.tsx b/packages/next/src/server/app-render/app-render.tsx index 392ecacb048c0..89a25bc6ed70f 100644 --- a/packages/next/src/server/app-render/app-render.tsx +++ b/packages/next/src/server/app-render/app-render.tsx @@ -1146,18 +1146,10 @@ async function renderToHTMLOrFlightImpl( // react-server-dom-webpack. This is a hack until we find a better way. if (ComponentMod.__next_app__) { const instrumented = wrapClientComponentLoader(ComponentMod) - // @ts-ignore + // @ts-expect-error globalThis.__next_require__ = instrumented.require - // When we are prerendering if there is a cacheSignal for tracking - // cache reads we wrap the loadChunk in this tracking. This allows us - // to treat chunk loading with similar semantics as cache reads to avoid - // async loading chunks from causing a prerender to abort too early. - // @ts-ignore - globalThis.__next_chunk_load__ = (...args: Array) => { - const loadingChunk = instrumented.loadChunk(...args) - trackChunkLoading(loadingChunk) - return loadingChunk - } + // @ts-expect-error + globalThis.__next_chunk_load__ = instrumented.loadChunk } if (process.env.NODE_ENV === 'development') { @@ -2237,19 +2229,13 @@ async function spawnDynamicValidationInDev( const nonce = '1' if (initialServerStream) { - const [warmupStream, renderStream] = initialServerStream.tee() - initialServerStream = null - // Before we attempt the SSR initial render we need to ensure all client modules - // are already loaded. - await warmFlightResponse(warmupStream, clientReferenceManifest) - const prerender = require('react-dom/static.edge') .prerender as (typeof import('react-dom/static.edge'))['prerender'] const pendingInitialClientResult = workUnitAsyncStorage.run( initialClientPrerenderStore, prerender, {}} clientReferenceManifest={clientReferenceManifest} ServerInsertedHTMLProvider={ServerInsertedHTMLProvider} @@ -2727,13 +2713,6 @@ async function prerenderToStream( } if (initialServerResult) { - // Before we attempt the SSR initial render we need to ensure all client modules - // are already loaded. - await warmFlightResponse( - initialServerResult.asStream(), - clientReferenceManifest - ) - const initialClientController = new AbortController() const initialClientPrerenderStore: PrerenderStore = { type: 'prerender', @@ -2741,7 +2720,7 @@ async function prerenderToStream( implicitTags: implicitTags, renderSignal: initialClientController.signal, controller: initialClientController, - cacheSignal: null, + cacheSignal, dynamicTracking: null, revalidate: INFINITE_CACHE, expire: INFINITE_CACHE, @@ -2794,7 +2773,8 @@ async function prerenderToStream( : [bootstrapScript], } ), - () => { + async () => { + await cacheSignal.cacheReady() initialClientController.abort() } ).catch((err) => { @@ -2866,7 +2846,7 @@ async function prerenderToStream( prerenderIsPending = false return prerenderResult }, - () => { + async () => { if (finalServerController.signal.aborted) { // If the server controller is already aborted we must have called something // that required aborting the prerender synchronously such as with new Date() @@ -2960,7 +2940,7 @@ async function prerenderToStream( : [bootstrapScript], } ), - () => { + async () => { finalClientController.abort() } ) @@ -3215,19 +3195,13 @@ async function prerenderToStream( } if (initialServerStream) { - const [warmupStream, renderStream] = initialServerStream.tee() - initialServerStream = null - // Before we attempt the SSR initial render we need to ensure all client modules - // are already loaded. - await warmFlightResponse(warmupStream, clientReferenceManifest) - const prerender = require('react-dom/static.edge') .prerender as (typeof import('react-dom/static.edge'))['prerender'] const pendingInitialClientResult = workUnitAsyncStorage.run( initialClientPrerenderStore, prerender, > = new Set() -const chunkListeners: Array<(x?: unknown) => void> = [] - -function trackChunkLoading(load: Promise) { - loadingChunks.add(load) - load.finally(() => { - if (loadingChunks.has(load)) { - loadingChunks.delete(load) - if (loadingChunks.size === 0) { - // We are not currently loading any chunks. We can notify all listeners - for (let i = 0; i < chunkListeners.length; i++) { - chunkListeners[i]() - } - chunkListeners.length = 0 - } - } - }) -} - -export async function warmFlightResponse( - flightStream: ReadableStream, - clientReferenceManifest: DeepReadonly -) { - let createFromReadableStream - if (process.env.TURBOPACK) { - createFromReadableStream = - // eslint-disable-next-line import/no-extraneous-dependencies - require('react-server-dom-turbopack/client.edge').createFromReadableStream - } else { - createFromReadableStream = - // eslint-disable-next-line import/no-extraneous-dependencies - require('react-server-dom-webpack/client.edge').createFromReadableStream - } - - try { - createFromReadableStream(flightStream, { - serverConsumerManifest: { - moduleLoading: clientReferenceManifest.moduleLoading, - moduleMap: clientReferenceManifest.ssrModuleMapping, - serverModuleMap: null, - }, - }) - } catch { - // We don't want to handle errors here but we don't want it to - // interrupt the outer flow. We simply ignore it here and expect - // it will bubble up during a render - } - - // We'll wait at least one task and then if no chunks have started to load - // we'll we can infer that there are none to load from this flight response - trackChunkLoading(waitAtLeastOneReactRenderTask()) - return new Promise((r) => { - chunkListeners.push(r) - }) -} - const getGlobalErrorStyles = async ( tree: LoaderTree, ctx: AppRenderContext diff --git a/packages/next/taskfile.js b/packages/next/taskfile.js index 28f9a4aac8b38..942566123206e 100644 --- a/packages/next/taskfile.js +++ b/packages/next/taskfile.js @@ -1670,6 +1670,40 @@ export async function copy_vendor_react(task_) { }) .target(`src/compiled/react-dom${packageSuffix}/cjs`) + // Until React gives as a way to hook into preloadModule, we need to patch + // it here so that we can track cache reads during dynamic I/O prerendering. + // Tracking __next_chunk_load__ calls instead, would not be sufficient + // because React caches the loaded chunks in a module-scoped map, and skips + // the __next_chunk_load__ call if it already has a cached promise in the + // chunk map. This can happen when a chunk is started to be loaded during a + // normal dev request (no prerender), while in parallel a prerender is + // triggered (for dynamic validation) that needs the same chunk. In this + // scenario we have no chance to track this chunk loading with the prerender + // cache signal. This would lead to the initial prerender getting aborted + // too early, and then triggering a dynamic I/O error during the final + // prerender. + function patchPreloadModule({ source, isProduction }) { + const replacement = `const { workUnitAsyncStorage } = require("next/dist/server/app-render/work-unit-async-storage.external"); + function preloadModule(metadata) { + const workUnitStore = workUnitAsyncStorage.getStore(); + const cacheSignal = workUnitStore?.type === 'prerender' ? workUnitStore.cacheSignal : undefined; + const promise = _preloadModule(metadata) + + if (promise && cacheSignal) { + cacheSignal.beginRead(); + return promise.finally(() => cacheSignal.endRead()); + } + + return promise + } + function _preloadModule(metadata) {` + + return source.replace( + 'function preloadModule(metadata) {', + isProduction ? outdent.string(replacement) : replacement + ) + } + function replaceSetTimeout({ code, file, @@ -1777,10 +1811,15 @@ export async function copy_vendor_react(task_) { !file.base.startsWith('react-server-dom-webpack-server.browser')) ) { const source = file.data.toString() - let newSource = source.replace( - /__webpack_require__/g, - 'globalThis.__next_require__' - ) + + let newSource = patchPreloadModule({ + source: source.replace( + /__webpack_require__/g, + 'globalThis.__next_require__' + ), + isProduction: file.base.endsWith('production.js'), + }) + if (file.base.startsWith('react-server-dom-webpack-server.edge')) { newSource = replaceSetTimeout({ code: newSource, @@ -1832,9 +1871,13 @@ export async function copy_vendor_react(task_) { !file.base.startsWith('react-server-dom-turbopack-server.browser')) ) { const source = file.data.toString() - let newSource = source - .replace(/__turbopack_load__/g, 'globalThis.__next_chunk_load__') - .replace(/__turbopack_require__/g, 'globalThis.__next_require__') + + let newSource = patchPreloadModule({ + source: source + .replace(/__turbopack_load__/g, 'globalThis.__next_chunk_load__') + .replace(/__turbopack_require__/g, 'globalThis.__next_require__'), + isProduction: file.base.endsWith('production.js'), + }) if (file.base.startsWith('react-server-dom-turbopack-server.edge')) { newSource = replaceSetTimeout({ diff --git a/test/e2e/app-dir/use-cache/app/(cached-layout)/inner-cache-with-client-component/page.tsx b/test/e2e/app-dir/use-cache/app/(cached-layout)/inner-cache-with-client-component/page.tsx new file mode 100644 index 0000000000000..9831e2211c407 --- /dev/null +++ b/test/e2e/app-dir/use-cache/app/(cached-layout)/inner-cache-with-client-component/page.tsx @@ -0,0 +1,11 @@ +import { Foo } from '../../client' + +export default async function Page() { + 'use cache' + + return ( +

+ +

+ ) +} diff --git a/test/e2e/app-dir/use-cache/app/(cached-layout)/layout.tsx b/test/e2e/app-dir/use-cache/app/(cached-layout)/layout.tsx new file mode 100644 index 0000000000000..7b07ca3cdfdf9 --- /dev/null +++ b/test/e2e/app-dir/use-cache/app/(cached-layout)/layout.tsx @@ -0,0 +1,13 @@ +'use cache' + +export default async function Root({ + children, +}: { + children: React.ReactNode +}) { + return ( + + {children} + + ) +} diff --git a/test/e2e/app-dir/use-cache/use-cache.test.ts b/test/e2e/app-dir/use-cache/use-cache.test.ts index 95a5adb476137..0da1836231897 100644 --- a/test/e2e/app-dir/use-cache/use-cache.test.ts +++ b/test/e2e/app-dir/use-cache/use-cache.test.ts @@ -1,5 +1,6 @@ import { nextTestSetup } from 'e2e-utils' import { retry, waitFor } from 'next-test-utils' +import stripAnsi from 'strip-ansi' const GENERIC_RSC_ERROR = 'An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error.' @@ -458,4 +459,17 @@ describe('use-cache', () => { const text = await browser.elementByCss('h2').text() expect(text).toBe('This page could not be found.') }) + + it('should not trigger dynamic I/O error for inner "use cache" functions with client components', async () => { + const outputIndex = next.cliOutput.length + const browser = await next.browser('/inner-cache-with-client-component') + const text = await browser.elementByCss('p').text() + expect(text).toBe('foo') + + const cliOutput = stripAnsi(next.cliOutput.slice(outputIndex)) + + expect(cliOutput).not.toContain( + 'Error: Route "/inner-cache-with-client-component": A component accessed data, headers, params, searchParams, or a short-lived cache' + ) + }) })