File tree Expand file tree Collapse file tree 1 file changed +22
-3
lines changed
packages/next/src/server/app-render Expand file tree Collapse file tree 1 file changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -1203,18 +1203,37 @@ async function renderToHTMLOrFlightImpl(
1203
1203
// to treat chunk/module loading with similar semantics as cache reads to avoid
1204
1204
// module loading from causing a prerender to abort too early.
1205
1205
1206
+ const shouldTrackModuleLoading = ( ) => {
1207
+ if ( process . env . NEXT_RUNTIME === 'edge' ) {
1208
+ return false
1209
+ } else {
1210
+ if ( ! renderOpts . experimental . dynamicIO ) {
1211
+ return false
1212
+ }
1213
+ const workUnitStore = workUnitAsyncStorage . getStore ( )
1214
+ return ! ! (
1215
+ workUnitStore &&
1216
+ ( workUnitStore . type === 'prerender' || workUnitStore . type === 'cache' )
1217
+ )
1218
+ }
1219
+ }
1220
+
1206
1221
const __next_require__ : typeof instrumented . require = ( ...args ) => {
1207
1222
const exportsOrPromise = instrumented . require ( ...args )
1208
- // requiring an async module returns a promise.
1209
- trackPendingImport ( exportsOrPromise )
1223
+ if ( shouldTrackModuleLoading ( ) ) {
1224
+ // requiring an async module returns a promise.
1225
+ trackPendingImport ( exportsOrPromise )
1226
+ }
1210
1227
return exportsOrPromise
1211
1228
}
1212
1229
// @ts -expect-error
1213
1230
globalThis . __next_require__ = __next_require__
1214
1231
1215
1232
const __next_chunk_load__ : typeof instrumented . loadChunk = ( ...args ) => {
1216
1233
const loadingChunk = instrumented . loadChunk ( ...args )
1217
- trackPendingChunkLoad ( loadingChunk )
1234
+ if ( shouldTrackModuleLoading ( ) ) {
1235
+ trackPendingChunkLoad ( loadingChunk )
1236
+ }
1218
1237
return loadingChunk
1219
1238
}
1220
1239
// @ts -expect-error
You can’t perform that action at this time.
0 commit comments