Commit 3da302fd authored by Luke Sandberg's avatar Luke Sandberg

Add regression test for concurrent error page compilation race

Verifies that concurrent requests to an app-router page with a syntax
error don't cause turbopack to hang from an invalidation storm when
multiple ensurePage('/_error') calls race to compile the fallback
pages-router error page.
Co-Authored-By: 's avatarClaude <noreply@anthropic.com>
parent 3535acd0
export default function RootLayout({
children,
}: {
children: React.ReactNode
}) {
return (
<html>
<body>{children}</body>
</html>
)
}
export default function Page() {
return <p>hello world</p>
}
import { nextTestSetup } from 'e2e-utils'
import { retry } from 'next-test-utils'
describe('dev-error-page-race', () => {
const { next } = nextTestSetup({
files: __dirname,
})
it('should handle concurrent requests to an erroring page without hanging', async () => {
// First, verify the page works normally
const html = await next.render('/')
expect(html).toContain('hello world')
// Introduce a syntax error to trigger the fallback error page path
await next.patchFile('app/page.tsx', 'export default () => <div/')
// Fire multiple concurrent requests to trigger concurrent ensurePage('/_error') calls.
// Before the fix, this could cause an invalidation storm in turbopack as multiple
// tasks raced to write the same error page endpoints with different parameters.
const results = await Promise.all([
next.fetch('/'),
next.fetch('/'),
next.fetch('/'),
])
// All requests should complete (not hang) and return 500
for (const res of results) {
expect(res.status).toBe(500)
}
// Fix the error and verify recovery
await next.patchFile(
'app/page.tsx',
`export default function Page() {
return <p>recovered</p>
}`
)
await retry(async () => {
const recovered = await next.render('/')
expect(recovered).toContain('recovered')
})
})
})
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