ISSUE DESCRIPTION A self-throwing global error component renders no last-resort UI If…
- User
ISSUE DESCRIPTION
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.
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /vinext, current file: none) bash-$
Assistant
Now update
renderAppPageErrorBoundary:Assistant
Now add the import:
Assistant
Now run the repro again:
Assistant
Summary of the change
Problem: when
app/global-error.tsx(or vinext's built-in default global error component) throws while rendering, the throw escaped the App Router render pipeline — the request ended in a bodyless/dev-overlay 500 with no UI at all.Fix:
-
New module
packages/vinext/src/server/app-global-error-fallback.tsbuildGlobalErrorFallbackResponse()— returns the built-in, valid last-resort HTML document (<!DOCTYPE html><html id="__next_error__">…, copy mirroring the built-in default global error UI) with the boundary's successful status (200),text/html,Varyparity,Cache-Control: no-store, and middleware response headers/Set-Cookiemerged in. The original boundary exception is never put in the body.isFrameworkControlFlowSignal()— recognisesredirect()/notFound()/forbidden()/unauthorized()plus the CSR / dynamic-server / static-gen bailout digests.
-
renderAppPageErrorBoundary()(app-page-boundary-render.ts) now awaits the boundary response only when the resolved boundary is the global error boundary; if that render fails it rethrows control-flow signals unchanged, logs the real error server-side, clears the request context and returns the fallback document. Localerror.tsxboundaries keep their exact previous code path/semantics.
Checklist
- Reproduced the reported error — built a temp fixture (throwing
global-error.tsx+ throwing page):/boomreturned 500 with Vite's error page and no last-resort UI, in both dev and production preview. - Confirmed the fix resolves it — same fixture now returns 200 with the built-in fallback document (exactly one
<html>/<body>), no leak of"page blew up"/"global error boundary exploded", in dev and prod preview. Also verified at unit level throughrenderAppPageErrorBoundary. - Edge cases considered/verified — middleware headers (
x-mw) and cookies (set-cookie: mw-cookie) preserved; localerror.tsxboundary still renders its own UI with 200 (no fallback);redirect()thrown from the global error component behaves exactly as before (signal rethrown, verified against the stashed baseline); async server-component global error also produces the fallback; RSC (.rsc) requests keep their existing flight-payload behavior; request context is cleared on the bail-out path; knip/unused-export, fmt, lint, type-check andvinext#buildall pass. - Ran existing tests — unit project (5867 passed; only pre-existing
tests/oxlint-prefer-shared-utils.test.tsfailures, which also fail on the untouched baseline), alltests/nextjs-compat/**(26 files),app-router-dev-server,entry-templates,features,app-router-production-server, plus the boundary/fallback unit suites. No tests were added or modified (all temp fixtures/scripts removed).
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →