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
I’ll first map the repository and locate global-error rendering and fallback handling, then identify or reproduce the self-throwing boundary path before making a focused change.
- Assistant
rgis unavailable, so I’ll usegrepand inspect the package source plus the existing error-boundary tests. - Assistant
The relevant implementation appears to be
app-fallback-renderer/app-page-boundary-render. I’ll read their source and targeted tests to understand where the global boundary’s own exception currently escapes and how response metadata is assembled. - Assistant
I need the complete error-boundary function and response finalizer. I’ll inspect those exact sections and search for existing built-in HTML response helpers, header/cookie merge utilities, and control-flow classifiers that the fix should reuse rather than duplicate.
- Assistant
The shell interpreted
!via history expansion. I’ll disable history expansion (safe for the persistent shell) and rerun the read-only inspection. - Assistant
The global boundary is intentionally unwrapped, so a throw during its RSC/SSR render escapes
renderAppPageErrorBoundary. The requested “built-in valid HTML fallback” likely belongs at this outermost render call. I’ll inspect the boundary response implementation, canonical built-in global error markup, navigation-signal classifier, and test conventions to determine exact status/header expectations. - Assistant
The likely canonical last-resort document is Next’s minimal
__next_error__HTML and status 200 (the boundary-render path already deliberately uses 200). I’ll verify where render errors become observable (before response creation versus lazy body consumption), then inspect unit-test patterns for directly mockingrenderAppPageErrorBoundarydependencies so I can reproduce without adding tests. - Assistant
A focused fix should only catch failures while rendering an already-selected global boundary; local boundary failures must continue escaping to their ancestor/global retry path, and navigation signals must be rethrown. The fallback response should merge middleware headers (including additive cookies), retain edge-runtime signaling, clear request context, and contain no exception text. I’ll inspect dispatch/execution catches to ensure this placement doesn’t interfere with retries or cookie collection, then create a temporary direct reproduction.
- Assistant
The renderer receives only
middlewareContext, and normal boundary responses preserve exactly those headers/cookies, so the last-resort response should use the same merge source. I’ll implement a small private helper inapp-page-boundary-render.ts, catch only around the final global-boundary render, rethrow recognized navigation/control-flow signals, and preserve normal behavior for local boundaries. Before editing, I’ll create a temporary Vitest file outside the repository test tree to demonstrate the current thrown result using synchronous mocked SSR failure. - Assistant
The first standalone runner attempt produced no useful output because this repository lacks that TS execution binary. The code path is nevertheless clear from inspection; I’ll now add the narrowly scoped recovery helper and then use the repository’s Vitest runner with a temporary, removed-after-run test to reproduce both before/after semantics.
- Assistant
Python is not installed, so no file changed. I’ll perform the same deterministic edit with Node, which is the repository’s native runtime.
- Assistant
The implementation now isolates recovery to global-boundary failures and constructs the canonical minimal document with normal HTML
Vary, content type, edge marker, and merged middleware headers. I’ll verify formatting/type/lint first, then run a temporary focused test covering: successful fallback, no leaked messages, header/cookie retention, local-boundary propagation, and navigation-signal propagation. - Assistant
Lint passes; only import formatting differs from the repository formatter. I’ll apply formatting and rerun the checks separately so each result is visible.
- Assistant
To exercise the exact exported function, I’ll add a temporary root test file (not an existing test and removed immediately afterward). Its common mock forces
handleSsrto reject, which is the observable server-side failure mode for a self-throwing global component. For local semantics, a route page error module causes selection of a non-global boundary. - Assistant
The runner only includes
tests/**, so the temporary root test was not discovered and was removed. I’ll repeat it undertests/, still deleting it in the same command. This does not modify or retain any repository test. - Assistant
The focused reproduction now passes all three cases and the temporary test was removed. I’ll run the existing boundary, response, RSC-error, and execution test suites most likely affected, followed by the package build/type checks and a final diff review.
- Assistant
All 115 targeted existing tests pass. I’ll now run the full static check and package build. If build regenerates tracked distribution files, I’ll inspect whether repository convention expects them; otherwise I’ll retain only the source fix.
- Assistant
Full static checks passed and the package build completed successfully (only its known virtual-module externalization warnings). I’ll inspect Git status/diff to ensure the build did not introduce unrelated tracked artifacts and review the final code for edge cases such as null headers and duplicate cookies.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.