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 let's find who calls
fallbackRenderer.renderErrorBoundary(i.e., the top level caller that catches errors from page rendering).Assistant
This is exactly the pages-router equivalent handling. Let's look at it closely as a reference implementation for app router.
Assistant
Let's find the actual catch block with
isInternalErrorRenderlogic.Assistant
We have actual Next.js source available. Let's inspect its handling of this exact scenario.
Assistant
Now let's temporarily add the reproduction fixture directly in app-basic (will revert with git checkout afterward).
Assistant
No python3 available; let's use the
replacetool by opening the file.Assistant
Now let's write a quick script to fetch this route and observe behavior.
Assistant
Let's place the script inside the repo so module resolution works.
Assistant
I'll create a temp test file under tests/ and run it with the project's test runner, then delete it.
Assistant
Good, it does use
startFixtureServer. Let's create a temp fixture app for reproduction, run both dev and prod scenarios, then delete after verifying the fix.Assistant
Since the relative depth is identical (
tests/fixtures/<name>/node_modules), symlinks will resolve correctly. Now let's write the repro test using this fixture.Assistant
Confirmed reproduction with a clean isolated fixture. Now let's check the production/preview scenario too.
Assistant
Let's view the current tail of
renderAppPageErrorBoundaryprecisely to make a clean edit.Assistant
Let's get exact line numbers for the renderAppPageErrorBoundary function to edit precisely.
Assistant
Now let's implement the fix. First update imports:
Assistant
Now let's add the fallback HTML builder function and hook it into
renderAppPageErrorBoundary.Assistant
No hidden chars. Let's just use
editwith line range 122:123 (blank line before function) to insert new content.Assistant
Now insert the new code at line 122 (the blank line before
function getDefaultExport).Assistant
Need a blank line before
function getDefaultExport. Let's fix that.Assistant
Now let's find and update the
renderAppPageErrorBoundaryfunction's tail to wrap it in try/catch.Assistant
Now let's replace the final
return renderAppPageBoundaryElementResponse(...)with a try/catch.Assistant
Now let's build/typecheck the package.
Assistant
Good, that covers our file. Now let's re-run the earlier reproduction tests to confirm the fix resolves the issue, for both dev and preview (prod) modes.
Assistant
Excellent! Dev mode fixed: 200 status, valid HTML fallback, no leaked error info in the body (only logged server-side). Now let's verify production/preview mode.
Assistant
Both dev and prod paths now return the built-in valid HTML fallback with status 200, without leaking the exception. Now let's test the "middleware headers/cookies preserved" requirement and the "navigation signal not swallowed" requirement.
Assistant
Middleware headers and cookies are preserved. Now let's test the navigation-signal scenario: what if the global-error component itself throws
redirect().Assistant
Confirmed identical behavior for navigation-signal case before/after — semantics preserved. Now let's revert the global-error.tsx fixture back to the self-throw scenario and confirm the local-error-boundary case (non-global) is unaffected.
Assistant
Now let's clean up all temporary reproduction artifacts and revert modifications to the shared fixture.
Assistant
Clean. Now let's run the broader test suite (or at least a wide relevant subset) to make sure nothing else broke.
Assistant
Confirmed pre-existing failures unrelated to my change (environment/oxlint binary related). The
shims.test.tstimeout was likely a flaky/environment timing issue in the full run. Let's verify that one too, in isolation, with my changes applied.Assistant
Confirmed: passes in isolation — the earlier timeout was a flaky full-suite-load timing issue unrelated to my change, and the oxlint failures are pre-existing environment issues. Let's run the integration test project as well to be safe.
Assistant
All 165 relevant tests pass. Let's also run the broader app-router integration tests set with a longer timeout, split into chunks to avoid tool timeout.
Assistant
All pass. Let's run the remaining app-router/app-rsc integration tests too.
Assistant
All pass. Let's run remaining app-router/app-rsc production/static-export tests as a final sweep.
Assistant
All pass. Let's also check
dev-error-overlay/app-router-dev-servertests since these relate to dev overlay behavior that could interact with our change.Assistant
All 163 tests pass. Let's do a final review of the diff.
Assistant
This is a clean, focused diff. Let's do a final sanity check: run the fmt/lint check for this file to ensure style compliance.
Assistant
Both formatting and lint pass cleanly. Let's confirm the working tree is exactly as intended and no stray files remain.
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.