Skip to content

Commit 2caf822

Browse files
authored
fix: Rspack dev gets stuck after removing a page (#80555)
Rspack's incremental build algorithm causes a situation where deleted entries in dynamic entries still get built. If a page is deleted, an infinite loop occurs in the corresponding `next-app-loader`, causing the entire compilation to hang. The root cause of the hang lies in `const resolvedPagePath = await resolver(matchedPagePath)` failing to resolve `resolvedPagePath`, preventing the loop from exiting. When `resolvedPagePath` doesn't exist, we should immediately throw an Error. This logic would also benefit webpack, as scenarios where pages are deleted during the execution of `next-app-loader` do occur.
1 parent e2e82e9 commit 2caf822

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

packages/next/errors.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -708,5 +708,6 @@
708708
"707": "Invariant app-page handler received invalid cache entry %s",
709709
"708": "Failed to persist Chrome DevTools workspace UUID. The Chrome DevTools Workspace needs to be reconnected after the next page reload.",
710710
"709": "`rspack.getModuleNamedExports` is not supported by the wasm bindings.",
711-
"710": "Unable to remove an invalidated webpack cache. If this issue persists you can work around it by deleting %s"
711+
"710": "Unable to remove an invalidated webpack cache. If this issue persists you can work around it by deleting %s",
712+
"711": "Can't resolve %s"
712713
}

packages/next/src/build/webpack/loaders/next-app-loader/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,8 @@ async function createTreeCodeFromPath(
251251
${createMetadataExportsCode(metadata)}
252252
}]`
253253
continue
254+
} else {
255+
throw new Error(`Can't resolve ${matchedPagePath}`)
254256
}
255257
}
256258

0 commit comments

Comments
 (0)