diff --git a/test/development/app-dir/dynamic-io-dev-errors/app/top-level-error/page.tsx b/test/development/app-dir/dynamic-io-dev-errors/app/top-level-error/page.tsx new file mode 100644 index 0000000000000..8460e726221ca --- /dev/null +++ b/test/development/app-dir/dynamic-io-dev-errors/app/top-level-error/page.tsx @@ -0,0 +1,5 @@ +export default async function Page() { + throw new Error('Kaputt!') + + return

This page always errors.

+} diff --git a/test/development/app-dir/dynamic-io-dev-errors/dynamic-io-dev-errors.test.ts b/test/development/app-dir/dynamic-io-dev-errors/dynamic-io-dev-errors.test.ts index 11bec15d6a176..952ccda61ca7b 100644 --- a/test/development/app-dir/dynamic-io-dev-errors/dynamic-io-dev-errors.test.ts +++ b/test/development/app-dir/dynamic-io-dev-errors/dynamic-io-dev-errors.test.ts @@ -43,6 +43,21 @@ describe('Dynamic IO Dev Errors', () => { ) }) + it('should not log unhandled rejections for persistently thrown top-level errors', async () => { + const cliOutputLength = next.cliOutput.length + const res = await next.fetch('/top-level-error') + expect(res.status).toBe(500) + + await retry(() => { + const cliOutput = next.cliOutput.slice(cliOutputLength) + expect(cliOutput).toContain('GET /top-level-error 500') + }) + + expect(next.cliOutput.slice(cliOutputLength)).not.toContain( + 'unhandledRejection' + ) + }) + // NOTE: when update this snapshot, use `pnpm build` in packages/next to avoid next source code get mapped to source. it('should display error when component accessed data without suspense boundary', async () => { const outputIndex = next.cliOutput.length