Unverified Commit c9b536e4 authored by Marcos Hernanz's avatar Marcos Hernanz Committed by GitHub

Skip stack frame module lookup while Rspack is rebuilding

Under next-rspack, the `Stats.compilation` kept from the previous build is a handle to the compiler's current compilation rather than a snapshot. Source-mapping a stack frame while a rebuild is in flight reads the module graph and module ids of the compilation being built, which panics in the Rspack binding and aborts the dev server.

Skip the lookup while the owning compiler's `Watching` is running so the frame is returned unmapped instead. This only applies when `NEXT_RSPACK` is set; webpack keeps the previous compilation as a snapshot and is unaffected.

Fixes #98213
parent 65c832c8
......@@ -69,6 +69,16 @@ function getModuleById(
id: string | undefined,
compilation: webpack.Compilation
) {
if (process.env.NEXT_RSPACK && compilation.compiler.watching?.running) {
// Unlike webpack, Rspack's `Compilation` object is not a snapshot: the one
// kept from the previous build is a handle to the compiler's current
// compilation. While the compiler is rebuilding, that compilation's module
// graph and module ids are not readable, and touching them panics and
// aborts the dev server. Treat the module as not found so the frame is
// returned unmapped instead.
return undefined
}
const { chunkGraph, modules } = compilation
return [...modules].find((module) => chunkGraph.getModuleId(module) === id)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment