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
Let me start by exploring the repository structure to understand what we're working with.
Assistant
This appears to be a Next.js-like framework called "vinext". Let me explore the packages structure.
Assistant
Now let me find where global error is rendered/handled in the SSR/RSC code. Let me search for where globalErrorModule is used.
Assistant
The issue is about a self-throwing global error component rendering no last-resort UI. Let me look at the app-fallback-renderer.ts which seems to be the key file.
Assistant
Let me look at
renderAppPageBoundaryResponsein app-page-boundary.ts.Assistant
Let me look at the RSC error handler and how the stream handles errors.
Assistant
Let me find where
renderErrorBoundaryis called and the dispatch logic.Assistant
Let me look at app-page-render.ts around lines 800-900.
Assistant
Let me look at
shouldRerenderAppPageWithGlobalErrorandrenderAppPageHtmlStreamWithRecovery.Assistant
Assistant
Assistant
Let me look at the existing unit tests for the fallback renderer and boundary render.
Assistant
Let me look at the rest of the test file, especially anything related to global error and self-throw.
Assistant
Now let me reproduce the issue. Let me create a temporary test that mimics the existing tests but with a self-throwing global error module.
Assistant
Now let me write a temporary test to reproduce the issue: a self-throwing global error module.
Assistant
I've reproduced the issue. The error propagates up and no fallback UI is rendered. Let me look for any existing static HTML fallback mechanism in the codebase.
Assistant
Let me look at the default-not-found module and any HTML error page concepts.
Assistant
Let me look at how
renderToReadableStream(rscRenderer) is implemented in the real flow.Assistant
Let me look at the rscStreamHintsPath / createRscRenderer to understand if the RSC render is sync or async (returns a stream).
Assistant
Let me look at the SSR handler to understand whether shell render errors are caught synchronously.
Assistant
In the real flow,
handleSsrawaitsrenderToReadableStreamand rethrows on shell error, sorenderAppPageErrorBoundaryrejects awaitably. Now let me check how Next.js handles this — search the .nextjs-ref for any static fallback page.Assistant
Let me check the changeset directory for hints about the intended fix.
Assistant
Let me look at the existing app-page-boundary-render.test.ts to understand the test patterns.
Assistant
Let me look at the createMiddlewareContext helper and how middleware headers/cookies are preserved.
Assistant
Let me look at
buildAppPageElementand the build error path.Assistant
Let me find the actual
buildAppPageElementfunction that has the try/catch calling renderErrorBoundaryPage.Assistant
Let me check the app-page-request.ts line 457 entry point.
Assistant
Let me search for any hardcoded static HTML error pages in the codebase.
Assistant
Let me look at app-page-execution.ts:315 which has a doctype error response.
Assistant
Let me check how
renderAppPageHtmlResponsehandles cookies and headers.Assistant
Let me look at where pending cookies are appended to the HTML response in the normal flow.
Assistant
Let me check how middlewareContext.headers is built and whether pending cookies are included.
Assistant
Let me look at where pending cookies are flushed for normal HTML/RSC responses.
Assistant
Let me generate the exact static HTML output of the default global error component (client-error variant) to use as a fallback.
Assistant
The test must be in tests/. Let me put it there.
Assistant
Let me get the full untruncated client-error HTML string.
Assistant
Let me check whether any non-entry server module imports react-dom/server directly.
Assistant
The HTML case is caught by a try/catch (SSR awaits the shell). Now let me view the exact static HTML string to hardcode as the fallback.
Assistant
The static HTML approach is most robust across runtimes. Let me reconsider: a cleaner approach is to retry the render through the existing pipeline with the built-in default module (reusing all header/cookie preservation). Let me first check whether the RSC entry context has access to render the default module. Let me look at how the default module is referenced and check
getDefaultExportusage in the boundary render.Let me reconsider — I'll implement a retry with the built-in default module through the same pipeline, which reuses header/cookie preservation and produces the real default UI. Let me view the full
renderAppPageErrorBoundaryagain and plan the refactor.Assistant
Let me look at
buildAppPageSpecialErrorResponseto mirror its clearRequestContext and header pattern for the static fallback.Assistant
Let me get the full HTML string without truncation by writing it as a JS string to a file.
Assistant
Let me check the
AppPageMiddlewareContexttype definition.Assistant
Let me read the full JSON-escaped HTML string.
Assistant
Rather than hand-copying, let me generate the fallback module programmatically so the embedded HTML exactly matches the default component output.
Assistant
Now let me view the generated file and append the helper function.
Assistant
Now let me append the helper function to the file.
Assistant
Now let me wire the fallback into
renderAppPageErrorBoundary. Let me open the file and edit.Assistant
Now let me add the import for the fallback helper.
Assistant
Now let me edit the
renderAppPageErrorBoundaryfunction to add the try/catch with fallback. Let me view the relevant section with line numbers.Assistant
Now let me wrap the render call in a try/catch with the fallback.
Assistant
The
replacetool needs the file to be scrolled to the location. Let me usegotofirst then edit. Actually, the issue is "Text not found in displayed lines" — I need to navigate to that area first. Let me usegoto.Assistant
Now let me clean up the temp test files and run my reproduction test.
Assistant
The fix works. Let me extend the temp test to cover edge cases: local error boundary throws should propagate, and middleware headers/cookies preserved.
Assistant
All edge cases pass. Now let me run the existing related tests to ensure I didn't break anything.
Assistant
All pass. Let me run a broader unit test set and typecheck the package.
Assistant
Now let me typecheck the package to ensure the new file compiles cleanly.
Assistant
Let me check the vitest project configuration to run the integration global-error compat test for regression.
Assistant
The nextjs-compat tests are in the integration project. Let me run the global-error compat test to verify no regression in the real dev/prod flow.
Assistant
All 22 compat tests pass. Now let me verify the real dev server end-to-end by temporarily making the fixture
global-error.tsxthrow, then reverting.Assistant
Let me check the test helpers import path.
Assistant
Let me create a standalone probe with a minimal vitest config to test the real dev server end-to-end.
Assistant
The integration project has setup. Let me create a temp vitest config that defines a single "probe" project including my probe file, with the same alias and no MSW (integration doesn't use MSW). Let me write it.
Actually, simpler: temporarily ADD my probe file to the integration include list... no, I shouldn't modify vite.config.ts (it's not a test, but modifying build config is risky and I'd need to revert).
Let me create a separate temp config file
probe.config.tsand run vitest with-c probe.config.ts. ThedefineConfigfrom vite-plus — can I use it with a single project? Let me just write a plain vitest config.Let me check what
vite-plus/testexports (the test framework). The probe usesvite-plus/test. The integration tests use that. Let me write a minimal config.Let me write probe.config.ts.
Assistant
Now let me temporarily make the fixture global-error.tsx throw, then run the probe.
Assistant
vitestisn't directly in .bin;vpis the runner. Let me find the actual vitest binary.Assistant
Excellent! The real dev server confirms the fix end-to-end: status 200, built-in fallback UI rendered, original error and self-thrown error both NOT exposed. Now let me revert the fixture and clean up probe files.
Assistant
Let me verify the fixture is unchanged and review my final changes.
Assistant
Let me review the final diff and the new file.
Assistant
The file looks good. Let me run the broader unit test suite to ensure nothing else broke. Let me check the full unit project size first.
Assistant
3 failed (in
oxlint-prefer-shared-utils.test.ts), 5867 passed. Let me verify those failures are pre-existing and unrelated to my change.Assistant
These failures are in an oxlint rule test. Let me verify they're pre-existing by stashing my changes and re-running.
Assistant
The 3 failures are pre-existing (they fail without my changes too). My change introduces no new test failures. Let me run the formatter and linter on my changed files to ensure they conform.
Assistant
Let me check what the formatter changed and verify the HTML string is intact.
Assistant
Let me re-run the reproduction test once more after formatting to confirm everything still works.
Assistant
All assertions pass. Let me run the linter on my changed files to ensure no lint errors (repo uses strict lint).
Assistant
Let me check whether the unused-exported constant would be flagged by knip, and consider making it non-exported.
Assistant
The exported
DEFAULT_GLOBAL_ERROR_FALLBACK_HTMLis only used internally, so knip would flag it as an unused export. Since the issue says "no new public interfaces," let me make it non-exported.Assistant
Now let me run knip to confirm no unused-export issues from my change.
Assistant
Knip only shows pre-existing config hints (no unused exports from my files). Let me check the full knip output for any unused exports.
Assistant
No unused exports. Let me do a final confirmation run of the most directly affected unit tests.
Assistant
All 120 tests pass. Let me do a final review of the complete diff.
Assistant
I accidentally staged the changes. Since
submituses unstagedgit diff, let me unstage them.Assistant
The new file is untracked, so plain
git diffwon't show it. Let me usegit add -N(intent-to-add) so it appears ingit diffas an unstaged addition.Assistant
Both files now appear in
git diff. Let me run a final typecheck to confirm everything compiles.Assistant
The 22 tsc errors are all in
apps/web/app/...(a demo app with missing db modules) — pre-existing and unrelated. None are in my files. Let me confirm.Assistant
Let me verify I didn't leave any stray probe test files.
Assistant
tests/app-page-probe.test.tsis pre-existing (committed). My only changes are the two files. Let me run the pre-existing probe test (it may exercise error boundaries) to ensure no regression.Assistant
All pass. Let me do a final review of the new file in full to confirm correctness.
Assistant
Let me verify
git diff(no args) shows both files fully so submission captures them.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.