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 start by exploring the repository structure and searching for code related to global error handling and fallback UI.
- Assistant
Let me search for global error component handling and related tests.
- Assistant
There's an app-fallback-renderer.test.ts - that seems relevant. Let me also search for more specific terms related to the issue.
- Assistant
rg is not found now? That's weird - it worked before. Let me try grep.
- Assistant
Let me look at agent notes and the global-error source path more closely.
- Assistant
Inspecting the fallback renderer and related error-handling code next.
- Assistant
Let me continue reading the file.
- Assistant
Let me continue reading.
- Assistant
Let me read the rest and also look at app-page-boundary-render and how errors during global-error are handled.
- Assistant
Looking at how error boundaries handle failures when the global error component throws.
- Assistant
Let me open the renderAppPageErrorBoundary function fully.
- Assistant
Checking tests and response/stream handling when the global error UI itself fails.
- Assistant
Searching for incomplete handling around global-error failure paths.
- Assistant
There's html.ts and http-error-responses.ts - those could be relevant.
- Assistant
Let me look at the nextjs-compat global-error tests and the default-global-error. Also check git history for related PRs and any draft changes. Also look at AGENTS.md for relevant info.
- Assistant
Let me check how boundary element responses handle secondary failures during global-error rendering.
- Assistant
Let me read renderAppPageBoundaryElementResponse
- Assistant
Let me look at renderAppPageBoundaryResponse in app-page-boundary.ts
- Assistant
Let me open renderAppPageBoundaryResponse
- Assistant
Let me read the rest of the file.
- Assistant
Let me trace the error handling path when the main page fails and then the error boundary also fails.
- Assistant
There's something at line 882 in app-page-execution. Let me read that section carefully.
- Assistant
The grep matched on packages/vinext/src/server/app-page-render.ts for those high line numbers. Let me re-stack.
- Assistant
Let me read around line 850-950 of app-page-render.ts
- Assistant
There's
shouldRerenderAppPageWithGlobalErrorandrenderAppPageHtmlStreamWithRecovery. Let me look at those carefully. - Assistant
Let me read app-page-stream.ts from line 116
- Assistant
Let me read from line 261
- Assistant
Let me continue reading.
- Assistant
Checking pages-router dual-error handling for a pattern, and looking for related failing tests.
- Assistant
Looking for recent related commits and where a last-resort HTML response might belong.
- Assistant
Let me look at the Next.js reference implementation if available, and also check recent changesets or agents skills for the issue.
- Assistant
Reviewing stream tests and searching Next.js for the last-resort HTML path.
- Assistant
Searching Next.js app-render for nested global-error failure handling.
- Assistant
python3 not available? Let try node.
- Assistant
Found something interesting -
__next_error__html id. Extracting that next. - Assistant
Searching for hard-coded HTML fallbacks and related vinext handling.
- Assistant
I'll write a small script file so the multi-line search is reliable.
- Assistant
The heredoc was mangled by shell history expansion. Using the create command instead.
- Assistant
I need to write the content using edit.
- Assistant
Now run it.
- Assistant
Hmm onShellError didn't show - maybe the source uses different names. Let me check the vinext codebase for how double failures of global error are currently handled. Perhaps I should write a reproduct...I understand the issue you're describing—it's about ensuring that if the global error component itself fails during rendering, we still provide a proper fallback UI without exposing the original error, while keeping response headers and cookies intact.
To tackle this, I should first explore the codebase to see how errors are currently handled in the rendering paths, especially in
renderAppPageHtmlStreamWithRecoveryandrenderAppPageErrorBoundary.Let me start by examining the relevant files to understand the current error handling mechanisms. I'll use git to check the current state of the codebase.
- Assistant
There's something in node-web-streams-helper.js around line 715 - a hard-coded HTML for
__next_error__. - Assistant
Let me look at how pagesIRA handles this and also look at SSR error path when global error throws. Let me also look at renderAppPageHtmlStreamWithRecovery and later app-page-render for how clean respo...
- Assistant
Looking at next error handling around GlobalError failure and related vinext code paths.
- Assistant
Let me look at app-ssr-entry and app-ssr-stream for error handling during SSR.
- Assistant
Checking for TODOs around crash recovery and inspecting how Next.js's error rendering fails.
- Assistant
There's getFallbackErrorComponents - the last resort because of custom error page failing. Let me find more of that.
- Assistant
Let me search Next.js app-page template for what happens when global error fails during render.
- Assistant
Let me look at how React SSR fails when onShellError is called. And also look at vinext's SSR for catch of shell errors.
- Assistant
Bash history expansion with
!is killing me. Let me avoid that character. - Assistant
Inspecting SSR shell-error behavior and existing recovery around global-error renders.
- Assistant
Let me look at catch at line 549 of app-ssr-entry.ts more carefully.
- Assistant
I'll craft a temporary reproduction around a throwing global-error boundary to confirm the failure mode.
- Assistant
Let me check AGENTS.md and the app-page dispatch error path.
- Assistant
Let me look at relation to React ErrorBoundary - if the global error is rendered as the component itself in createElement(errorBoundary.component, {error}), and that component throws during RSC render...
- Assistant
Checking recent commits and changesets related to this behavior.
- Assistant
We're in a detached HEAD. Let me look at git show for commit about matching streaming metadata error responses - that might be related. Also search for "successful fallback status" phrase.
- Assistant
Inspecting the error boundary shim when its fallback throws.
- Assistant
Looking for a static last-resort HTML in Next app-render for SSR failures.
- Assistant
There's ErrorApp in next.js app-render at line 2016. Let me extract that section.
- Assistant
Write search for ErrorApp
- Assistant
Run it
- Assistant
There's a catch (finalErr) after the error HTML stream rendering. Let me get that section.
- Assistant
Run it
- Assistant
Hmm Next.js just rethrows finalErr. So what is the "built-in valid HTML fallback"?
- Assistant
Checking fixtures and related isues for self-throwing global-error cases.
- Assistant
Reproducing with a focused unit stay: rendering the error boundary when global-error itself throws.
- Assistant
I'll write a temp script that calls the functions directly without vitest to understand behavior.
- Assistant
Let me run this with vitest or tsx/node. Check how packages are run.
- Assistant
Let me try running with npx tsx or node --experimental-strip-types, or use vitest.
- Assistant
That timed out. Let me try differently - run with node and the dist files that are already built.
- Assistant
Let me use tsx with the source files and proper resolution.
- Assistant
I'll use tsx to run a simplified script importing from dist.
- Assistant
Run with node
- Assistant
Need to run from the repo with NODE_PATH or put the file in the repo.
- Assistant
Confirmed: a throwing global-error bubbles with no UI. Checking how React SSR is used on the server and implementing a static fallback.
- Assistant
I'll implement a static HTML fallback. Prefer harder-coded HTML to avoid depend on react-dom in the hot boundary path high that might not be available in Edge RSC cont...
- Assistant
Reviewing default-global-error markup and boundary-render end so we can add a solid static fallback.
- Assistant
Implementing recovery: when global-error rendering fails, retry the built-in default element, then astatic HTML homepage as last resort.
- Assistant
I'll write the fallback helper. Keep HTML simple but valid matching key default UI strings.
- Assistant
Fixing the charset attribute and wiring recovery into the error-boundary renderer.
- Assistant
Fix charset in HTML and update boundary-render.
- Assistant
Now update app-page-boundary-render.ts to use this.
- Assistant
Now replace the end of renderAppPageErrorBoundary function.
- Assistant
The replace tool might need the file open at the right place. Let me goto line 428 first and try again, or use a smaller unique string.
- Assistant
Now try edit with line ranges for the replacement.
- Assistant
Updating the repro to importžd from source and verifying the fix.
- Assistant
Let me just use tsx to run oregon. a .ts file_directly.
- Assistant
Write the repro as TS
- Assistant
Run with tsx
- Assistant
Wrap in main async
- Assistant
Run again
- Assistant
Also verifying the path where the real default é component throws, falling through to static HTML.
- Assistant
There's a duplicate main() and broken syntax. Let me fix the whole end of the file.
- Assistant
Run again
- Assistant
The last case uses static HTML (DOCTYPE present). Verifying local error boundary still throws as before.
- Assistant
Write a short test for local error throwing
- Assistant
Run local test
- Assistant
Running related unit tests and cleaning up temporary files.
- Assistant
Tests timed out - maybe vp is slow. Let try with vitest. directly or longer timeout.
- Assistant
Let me try running tests with a longer approach - background? Or just vp test with artist file.
- Assistant
Good. Running more related tests.
- Assistant
Simplifying headElements handling and reviewing the final code.
- Assistant
Need to goto the line first.
- Assistant
Now replace
- Assistant
Cleaning leftovers and double-checking the final diff.
- Assistant
Checking how submit handles new untracked files —
git diffalone misses them. - Assistant
Staging the new file with intent-to-add so
git gett diffincludes it.
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 →