mirror of
https://github.com/vercel/next.js.git
synced 2026-09-20 02:25:18 +08:00
6d67f46a4d
Backports #96988 ("Keep the dev validation worker alive across HMR updates") to `next-16-3`. Cache Components dev validation reported stack frames that pointed at build output whenever a module had been updated while the dev server ran. The overlay showed a raw `file:` URL, the terminal named the chunk rather than the page, and because the frame never resolved to a source position there was no code frame either, so nothing indicated which line caused the error. This affected both the static shell validation and the instant-navigation validation, since both run on the same worker. Turbopack's server HMR evaluates an updated module as a script of its own, carrying its source map inline rather than on disk, so only the isolate that ran that `eval` can resolve a frame in it. The validation worker never ran it. The worker now replays the applied updates, the cleared manifest cache entries, and the evicted paths that the dev server reports, in the same order the dev server applied them, which leaves each updated module's inline source map in the worker's own Node.js cache. Not dropping the worker on every edit also removes a worker respawn and a `loadComponents` call from each validation that follows an edit, which is paid at exactly the moment the user is waiting for the insight. The case in the test suite that covers this went from around 870ms to around 240ms. This affects Turbopack dev with Cache Components, which is on by default unless `experimental.devValidationWorker` is set to `false`. ### Verification on this branch Cherry-picked from `f70564f742` with no conflicts. All source files are byte-identical to canary. Behavioral verification is left to CI on this branch; the change carries the `dev-validation-worker-source-maps` suite, whose snapshots turn from a frame naming the chunk into resolved frames. <!-- NEXT_JS_LLM -->