Unverified Commit ff8e02d1 authored by vercel-fleet-prod[bot]'s avatar vercel-fleet-prod[bot] Committed by GitHub

fix(next-rspack): avoid release build panics

Co-authored-by: 's avatarTobias Koppers <1365881+sokra@users.noreply.github.com>
parent ba182aa1
......@@ -69,6 +69,18 @@ function getModuleById(
id: string | undefined,
compilation: webpack.Compilation
) {
// Rspack reuses its native Compilation allocation between rebuilds, so a
// Stats object retained from the previous build aliases the build in
// progress. Reading its module graph while Rspack has stolen the graph
// artifact aborts the process instead of throwing a JavaScript error. A
// failed compilation can likewise have no code generation results to read.
if (
process.env.NEXT_RSPACK &&
(compilation.compiler.watching?.running || compilation.errors.length > 0)
) {
return undefined
}
const { chunkGraph, modules } = compilation
return [...modules].find((module) => chunkGraph.getModuleId(module) === id)
......
......@@ -64,6 +64,14 @@ describe('server-navigation-error', () => {
`)
})
it('keeps the dev server running after mapping middleware errors', async () => {
const browser = await next.browser('/middleware/redirect')
// Reloading asks the overlay to map the error while Rspack is rebuilding.
await browser.refresh()
expect((await next.fetch('/')).status).toBe(200)
})
it('should error on navigation API not-found', async () => {
const browser = await next.browser('/middleware/not-found')
......
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