Skip to content
TheChatArchiveThe Chat Archive
Claudeclaude-sonnet-5· anthropicHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

ISSUE DESCRIPTION A self-throwing global error component renders no last-resort UI If…

  1. 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 using git reset --hard command. Additionally, you can use git stash and git stash pop to temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call submit) using git status or git diff commands. However you don't need to use git add or git commit before submitting your changes. In fact, submit only submits currently unstaged changes because it uses git diff to 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-$

  2. Claude Assistant

    Now let's look at applyEdgeRuntimeHeader:

  3. Claude Assistant

    Now let's update renderAppPageErrorBoundary to use this fallback when the global error boundary itself throws.

  4. Claude Assistant

    Now let's update the tail of renderAppPageErrorBoundary to wrap the render call in try/catch.

  5. Claude Assistant

    Looks fine; let's just use edit with explicit line range instead.

  6. Claude Assistant

    No errors. Let's check the vp check / lint scripts referenced at root for a proper type check across the repo.

  7. Claude Assistant

    Good, it did run against that tsconfig with no errors. Now let's write a small reproduction test to confirm the fix using the existing test infrastructure (app-fallback-renderer.test.ts style), without permanently modifying test files.

  8. Claude Assistant

    Now let's look at the "global-error boundaries" test and createCommonOptions/createMiddlewareContext helpers for constructing a temp reproduction script.

  9. Claude Assistant

    The test passes, confirming the fix works. Now let's verify the pre-fix behavior would have failed (i.e., without the fix the test would throw). Let's temporarily revert and check.

  10. Claude Assistant

    Confirmed the bug reproduces without the fix, and the fix resolves it. Let's restore the fix.

  11. Claude Assistant

    Now let's also verify special-error and local-boundary preservation behave as intended with additional quick checks in the temp test file, then remove it before final submission.

  12. Claude Assistant

    All three scenarios behave as intended. Now let's remove the temp test file and run the broader existing test suites related to this area to make sure nothing broke.

  13. Claude Assistant

    So entry-templates.test.ts and nextjs-compat/global-error.test.ts are part of the integration project. Let's run those (may take longer).

  14. Claude Assistant

    Now let's run the nextjs-compat global-error test (integration project) which does a full dev server run — this is a good end-to-end sanity check.

  15. Claude Assistant

    All 22 pre-existing tests pass. Now let's run the broader unit test project fully to make sure nothing else broke.

  16. Claude Assistant

    All unit tests pass (5870 passed, 2 skipped — pre-existing skips unrelated to our change). Let's also quickly run the integration project fully to be thorough, though it may take a while.

  17. Claude Assistant

    Both pass. Let's also verify the type-check/lint for the whole vinext package once more (full check) to be safe.

  18. Claude Assistant

    Now let's review the diff one more time for sanity.

  19. Claude Assistant

    This looks correct. Let's also double check the new file content once more.

  20. Claude Assistant

    Good, structurally valid. Let's remove this temp test file now.

  21. Claude Assistant

    Good, this confirms the pattern: synchronously-built (non-streamed) fallback responses call clearRequestContext() immediately. Let's add this to our last-resort path too.

  22. Claude Assistant

    Let's also re-verify the reproduction scenarios once more end-to-end with the added clearRequestContext call, using a fresh temp test, then delete it.

  23. Claude Assistant

    Headers, cookies, and context clearing all confirmed. Let's clean up temp files.

  24. Claude Assistant

    Now let's run the full unit test suite once more (final confirmation) and the targeted integration tests.

  25. Claude Assistant

    All unit tests pass. Let's re-run the nextjs-compat/global-error integration test once more to make sure the additional clearRequestContext() call didn't regress anything there.

  26. Claude Assistant

    All tests pass. Let's do a final review of the complete diff.

  27. Claude Assistant

    This looks complete and correct. Let's go through the checklist.

  28. Claude Assistant

    Summary

    I resolved the issue by adding a guaranteed-safe "last resort" fallback for the App Router's global error boundary rendering path.

    Root cause: renderAppPageErrorBoundary (in app-page-boundary-render.ts) selects a boundary component (a local error.tsx, or — when none exists — app/global-error.tsx/vinext's built-in default) and renders it. If that selected component itself throws while rendering (a bug in the user's global-error.tsx, for instance), the exception propagated all the way up through renderAppPageHtmlStreamWithRecovery → renderAppPageLifecycle → the RSC handler, uncaught — producing no usable response ("no last-resort UI").

    Fix:

    1. Added packages/vinext/src/server/app-page-last-resort-fallback.ts: a self-contained, static (non-React) HTML string mirroring the built-in DefaultGlobalError UI ("This page couldn't load" / "A server error occurred. Reload to try again."), plus buildAppPageLastResortResponse() which wraps it in a Response with status 200, merging in any existing middleware headers/cookies via the same mergeMiddlewareResponseHeaders helper used elsewhere. Being pure string content, this can never throw itself.
    2. Wrapped the render call in renderAppPageErrorBoundary in a try/catch:
      • If the caught error carries a digest (redirect/notFound/forbidden/unauthorized signal from resolveAppPageSpecialError), it's rethrown unchanged — framework navigation/control-flow semantics are preserved.
      • If the boundary that failed was a local error.tsx (!errorBoundary.isGlobalError), it's rethrown unchanged — local error boundary behavior is untouched/out of scope.
      • Otherwise (the global error boundary itself failed), it logs both the original and the boundary's own exception server-side only (never exposed to the client) and returns the static last-resort Response, also synchronously clearing per-request context since this response bypasses the normal streaming path.

    Verification: Wrote and ran temporary reproduction tests (removed before submitting) proving: (a) a self-throwing global-error now yields a 200 HTML fallback without leaking either exception's message, (b) a self-throwing local error.tsx still propagates unchanged, (c) a digest-bearing signal thrown from the global boundary still propagates unchanged, and (d) headers/cookies from middlewareContext are preserved and clearRequestContext is invoked. Ran the full unit suite (5870 passed, 2 pre-existing skips) plus targeted integration suites (nextjs-compat/global-error.test.ts, entry-templates.test.ts, app-router-dev-server.test.ts, app-router-production-server.test.ts) — all green. tsc --noEmit on the vinext package is clean.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.