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
Good, this confirms
mergeMiddlewareResponseHeadershandles Set-Cookie preservation. Now let's create the static last-resort fallback module and wire it intorenderAppPageErrorBoundary.Assistant
Now let's wire this into
renderAppPageErrorBoundaryinapp-page-boundary-render.ts.Assistant
Now let's view and modify the
renderAppPageErrorBoundaryfunction.Assistant
Looks fine; maybe there's a trailing line issue. Let's use
editwith explicit line range instead.Assistant
Now let's use
editwith explicit line numbers 449:459.Assistant
Now let's add the missing import for
DEFAULT_GLOBAL_ERROR_MODULE.Assistant
Now let's check TypeScript compiles for this package.
Assistant
Compiles cleanly. Now let's rerun our repro test to validate behavior for the self-throwing global-error scenario (dev mode).
Assistant
Let's look for existing
renderAppPageErrorBoundarytests to see calling conventions.Assistant
All 4 unit tests pass, validating each scenario precisely. Now let's run the full existing test suite (relevant files) to ensure nothing broke.
Assistant
All pass. Now let's run the nextjs-compat global-error test suite specifically.
Assistant
All 57 pass. Now let's run the broader unit test suite for a wider safety net.
Assistant
All other 5875 unit tests pass; the only failure is our own temporary repro test (timeout unrelated to correctness — a parallel-run quirk). Let's clean up temporary test artifacts now.
Assistant
Good, clean diff. Let's run the integration test suite once more (broader) to double check nothing else regressed, plus the relevant boundary/fallback tests one more time.
Assistant
All 318 tests pass. Let's also run lint/format checks to comply with repo conventions.
Assistant
Lint and format both clean. Let's do a final review of the diff.
Assistant
This looks correct and complete. Let's view the new file once more for final sanity.
Assistant
This is solid. Let's do one final full check of the git diff and status before submitting.
Assistant
Now let's go through the checklist explicitly.
Checklist review:
-
If an error was reported in the issue description, I have successfully reproduced it. ✅ I built a fixture where
global-error.tsxitself throws and confirmed via dev-mode and production-preview runs that the request previously either surfaced a raw dev error overlay or (in production) an HTML page leaking the exception's message/stack trace with a500status and no valid last-resort UI — matching "renders no last-resort UI" and the exposure concern from the issue. -
If an error was reported in the issue description, I have confirmed that my fix resolves the error. ✅ After the fix, the same scenario returns a
200response with valid HTML: first attempting vinext's built-inDefaultGlobalErrorcomponent (using the original sanitized error, not the boundary's own exception), and — only if that also fails — a fully static, hand-written HTML fallback that contains no error details at all. Verified via both dev and production-preview runs, and via four targeted unit tests exercising: local-boundary rethrow, navigation-signal rethrow, built-in-component retry success, and the terminal static fallback (with header/cookie preservation).
-
Assistant
-
I have thought about edge cases and made sure my fix handles them as well. ✅ Covered:
- Local (non-global) error boundary throws → rethrown unchanged (existing semantics preserved, not swallowed).
- Navigation/control-flow signals (redirect/notFound/forbidden/unauthorized digests) thrown while rendering the boundary → rethrown unchanged so existing special-error handling still applies.
- App's own
global-error.tsxthrows, but a custom one was supplied → retried with vinext's built-in default component (safe, deterministic markup) using the original app error, so users still see a meaningful "server error" placeholder instead of a blank crash. - Even the built-in default component fails (or the effective
globalErrorModulewas already the default) → falls to a fully static, hand-authored HTML string with zero dynamic/error content, guaranteed not to throw again. - Response headers/cookies (e.g. middleware
Set-Cookie, custom headers) are preserved on every fallback tier via the samemergeMiddlewareResponseHeadershelper used elsewhere. - The boundary's own second exception is only ever
console.error-logged server-side, never serialized into the response.
-
I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. ✅ Ran the full unit test project (5875 tests passed, only my own temporary repro test — since removed — timed out due to parallel test-runner overhead, not a regression), plus targeted reruns of
app-page-boundary-render.test.ts,app-fallback-renderer.test.ts,app-page-stream.test.ts,app-page-element-builder.test.ts,nextjs-compat/global-error.test.ts,nextjs-compat/global-not-found.test.ts,nextjs-compat/not-found.test.ts,entry-templates.test.ts, andapp-router-dev-server.test.ts(318 tests, all passing). Also verifiedvp lintandvp fmt --checkare clean, andtsc --noEmitcompiles without errors. All temporary fixtures/scripts/tests created for investigation have been removed, leaving a clean diff of just the two source files.
-
Assistant
Everything is clean and verified. Submitting the changes now.
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 →
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 →