A self-throwing global error component renders no last-resort UI If the global error…
- User
A self-throwing global error component renders no last-resort UI
If the global error component itself fails, return the built-in valid HTML fallback with the expected successful fallback status while preserving response headers and cookies. Local error boundaries and framework navigation/control-flow signals must retain their existing semantics, and the original boundary exception must not be exposed.
Interface
No new public interfaces are introduced.
- Assistant
I’ll trace the App Router global-error fallback path, compare it with the local Next.js reference tests/source, then add a focused regression test and run only the relevant checks.
- Assistant
The workspace has no
rg, and the local.nextjs-refclone is absent. Since external access is disallowed for this task, I’ll use local repository searches and existing compatibility tests as the behavioral reference. - Assistant
The failure is in the typed App Router fallback renderer: a custom
global-erroris already the final boundary, so its own render exception currently escapes. I’m adding a one-shot built-in HTML response there, limited to global-boundary failures, with status 200 and the same middleware headers/cookies. Local boundaries and navigation signals will continue through their existing paths. - Assistant
A packaged local Next.js 16 source is available in
node_modules, so I can verify the upstream behavior without network access. I’m checking its final render-error branch now before locking the fallback markup. - Assistant
The focused regression now covers the empty
__next_error__document, 200 status, middleware headers andSet-Cookie, non-disclosure of both exceptions, plus unchanged local-boundary and redirect behavior. I’m running the boundary tests and type/lint checks next. - Assistant
vpis not installed in this environment, so I’m using the repository’s equivalentpnpm testand check scripts. - Assistant
All three relevant test files pass (43 tests total). The formatter found only the new test file, so I’m applying that mechanical format and then running the type-aware check.
- Assistant
The unit path is clean, and the local Next.js source confirms the empty
<html id="__next_error__">shell. I’m adding one fixture-level request test as a final check that the real RSC→SSR pipeline rejects early enough for this recovery path, including middleware header/cookie preservation. - Assistant
The real pipeline exposed a second path: ordinary middleware headers reach the fallback, but cookies are tracked separately from
Headers. I’m threading the existing pending-cookie drain into the last-resort response so cookies set before the render failure survive too; this stays internal and adds no public API. - Assistant
The end-to-end fixture now confirms the actual SSR pipeline returns the exact empty error document with status 200 and preserved middleware headers. Pending render cookies are also attached by the focused unit path. I’m doing the final full targeted test set and repository check.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.