Skip to content
TheChatArchiveThe Chat Archive
GLMz-ai/glm-5.2· unknownHugging 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. GLM Assistant

    Let me explore the repository structure first.

  3. GLM Assistant

    Now let me look at how the error boundary rendering handles errors when the global error component itself fails. Let me look at renderAppPageBoundaryResponse and renderAppPageHtmlResponse and the SSR handler to see where errors during rendering are caught.

  4. GLM Assistant

    Now I see that the SSR handler is what renders the HTML. The error happens during SSR streaming. Let me look at how the page render handles errors, particularly the recovery mechanism. Let me look at renderAppPageHtmlStreamWithRecovery and how it's used in the page render path.

  5. GLM Assistant

    Now I understand the architecture. Let me understand the issue: when the global error component itself fails (during the error boundary render path), what happens? Let me trace the path.

    When a render error occurs, the flow is:

    1. renderAppPageHtmlStreamWithRecovery catches the error
    2. Calls options.renderErrorBoundaryResponse(error) which calls renderErrorBoundary → renderAppPageErrorBoundary
    3. This renders the global error component

    If the global error component itself throws, what happens? The error boundary render would throw, and renderErrorBoundaryResponse would return... let me check. Actually renderAppPageErrorBoundary returns Promise<Response | null> and inside it calls renderAppPageBoundaryElementResponse → renderAppPageBoundaryResponse → createHtmlResponse → renderAppPageHtmlResponse → renderAppPageHtmlStream.

    But wait, the error in the global error component would happen during SSR streaming, which is lazy. So when does the error actually surface?

    Let me think about this more carefully. The SSR render happens when the stream is consumed. The error from the global error component during SSR streaming would surface as a stream error, not as a synchronous throw in renderAppPageHtmlResponse.

    Actually wait. Let me reconsider. The renderAppPageHtmlStream calls options.ssrHandler.handleSsr(...). This returns a stream. The shell render happens during this. If the global error component itself throws during the shell render (synchronously while building the shell), then handleSsr would reject, and renderAppPageHtmlStream would throw.

    But this is inside renderErrorBoundaryResponse, which is called from renderAppPageHtmlStreamWithRecovery. At that point, we're already in the catch block. If renderErrorBoundaryResponse throws, the error propagates up.

    Hmm, but the issue says "renders no last-resort UI". So the bug is: when the global error component itself fails, there's no fallback UI rendered. The desired behavior is to return the built-in valid HTML fallback.

    Let me look at the actual SSR handler to understand where errors during rendering surface.

  6. GLM Assistant

    Now I understand the SSR pipeline. Let me look at the default global error module and the built-in HTML fallback.

  7. GLM Assistant

    Now let me look at how the render flow is dispatched and where the error boundary response is invoked. Let me look at the page render dispatch.

  8. GLM Assistant

    Let me look at the dispatch flow and where the final fallback happens.

  9. GLM Assistant

    Let me look at the top-level request handling where errors are caught and the fallback HTML is generated.

  10. GLM Assistant

    Let me find the top-level request handler and where dispatch errors are caught.

  11. GLM Assistant

    This is a generated entry. Let me look at the actual request pipeline where errors get caught and where the final fallback is. Let me look at the request-pipeline.ts and how renderAppPage/dispatchAppPage is wrapped.

  12. GLM Assistant

    Let me look at the actual request handler that catches top-level errors. Let me look at the app-rsc-handler.ts which seems to be the main request handler.

  13. GLM Assistant

    Now let me understand where the page render itself happens (the dispatchAppPage result). Let me see the section after the route is matched.

  14. GLM Assistant

    Let me find the top-level catch that produces a final response when the whole dispatch throws.

  15. GLM Assistant

    Let me look at the prod-server and the top-level worker fetch handler.

  16. GLM Assistant

    Let me look at the tests to understand the expected behavior.

  17. GLM Assistant

    Let me look at the global-error.tsx fixture and the global-error-rsc page.

  18. GLM Assistant

    Let me look at the full renderAppPageErrorBoundary function and its options type.

  19. GLM Assistant

    Let me look at how the error is sanitized and the digest is computed.

  20. GLM Assistant

    Let me check the app-ppr-fallback-shell.ts and any static HTML helpers.

  21. GLM Assistant

    Let me look at the changeset directory and recent changes for context.

  22. GLM Assistant

    Let me look at the existing unit test for the boundary render.

  23. GLM Assistant

    Let me first try running the existing unit test to confirm the test infrastructure works.

  24. GLM Assistant

    Let me look at the dev-server test pattern to set up a reproduction.

  25. GLM Assistant

    Let me create a temporary fixture with a self-throwing global error and a page that throws, then run a quick reproduction. But modifying the app-basic fixture's global-error.tsx would break existing tests. Let me create a separate fixture directory.

    Actually, let me create a temporary test that uses a custom fixture. Let me look at the helpers to understand startFixtureServer.

  26. GLM Assistant

    Let me create a temporary fixture with a self-throwing global error and a page that throws, and a temporary test.

  27. GLM Assistant

    The test runner only includes specific files. Let me place the repro test inside the tests/ directory temporarily.

  28. GLM Assistant

    Let me rewrite the test file cleanly and put the fixture in tests/fixtures.

  29. GLM Assistant

    The integration project has a specific include list. Let me check the vitest config to find the projects. Let me rename the test to match one of the included patterns, or use a different approach. Let me check the vitest config.

  30. GLM Assistant

    The unit project includes tests/**/*.test.ts. Let me run the repro test as a unit test.

  31. GLM Assistant

    I've reproduced the issue: status 500 instead of 200. Let me see the full output to confirm the HTML content.

  32. GLM Assistant

    Let me look at how the dev server handles SSR errors.

  33. GLM Assistant

    Let me find the App Router dev request handler and where the 500 comes from.

  34. GLM Assistant

    Let me look at how the dev server serves the app router. The dev server likely uses the generated app-rsc-entry. The 500 with the Vite overlay comes from the dev server's error handling. Let me look at where the app router request is dispatched in dev.

  35. GLM Assistant

    Let me find how the dev server actually invokes the app router. The dev server middleware likely loads the rsc-entry module and calls its default handler. Let me search for where the rsc entry's default export is called in dev.

  36. GLM Assistant

    Let me look at the top of app-router-entry to understand the dev path.

  37. GLM Assistant

    This is the prod worker entry. The dev server must use a different path. Let me look at how the dev server invokes the app router. Let me search the index.ts (the main vinext plugin) for the dev server middleware.

  38. GLM Assistant

    Now I understand the flow. Let me check the imports of app-page-boundary-render.ts to see what's available.

  39. GLM Assistant

    Let me look at createInitialDevServerErrorScript to understand the dev overlay mechanism.

  40. GLM Assistant

    Let me check mergeMiddlewareResponseHeaders to confirm cookies are preserved.

  41. GLM Assistant

    Good, cookies/headers are preserved through the existing pipeline. Now let me view the exact lines of renderAppPageErrorBoundary to edit.

  42. GLM Assistant

    Let me check what's exported from app-page-boundary.js for the result type.

  43. GLM Assistant

    Let me add the import for DEFAULT_GLOBAL_ERROR_MODULE.

  44. GLM Assistant

    Now let me add the import. Let me view lines 9-25.

  45. GLM Assistant

    Now let me modify the renderAppPageErrorBoundary function. Let me view its current exact content with line numbers.

  46. GLM Assistant

    Now let me edit the final return block to wrap it in try/catch with the fallback. Let me get exact line numbers.

  47. GLM Assistant

    Now let me replace the element-building + return block (lines 427-458) with a version that wraps the render in try/catch and falls back to the built-in default global error.

  48. GLM Assistant

    Now let me run the repro test to verify the fix works.

  49. GLM Assistant

    The fix works in dev. Let me verify the HTML content and that the original exception isn't exposed.

  50. GLM Assistant

    Let me rewrite the repro test to check assertions and add a prod preview test.

  51. GLM Assistant

    The dev overlay script intentionally exposes the error for developer tooling (existing pattern). Let me check what the app-basic fixture has for build setup, so I can make a buildable prod fixture.

  52. GLM Assistant

    Let me look at app-basic's config files to create a buildable prod fixture.

  53. GLM Assistant

    Let me make the minimal fixture buildable by adding config files.

  54. GLM Assistant

    Let me relax the dev test assertion (dev overlay intentionally exposes the error) and run again.

  55. GLM Assistant

    Both dev and prod tests pass. Now let me strengthen the test to verify headers/cookies preservation by adding a middleware to the fixture. Let me check the middleware format.

  56. GLM Assistant

    Let me add a simple middleware to the fixture to verify header/cookie preservation.

  57. GLM Assistant

    Excellent! Both dev and prod tests pass with header/cookie preservation. Now let me run the existing related tests to ensure I didn't break anything.

  58. GLM Assistant

    All 22 global-error compat tests pass. Let me run the broader app-router dev server tests which exercise error boundaries.

  59. GLM Assistant

    All 163 tests pass. Let me run the production server tests too.

  60. GLM Assistant

    Let me check resolveAppPageSpecialError and navigation signal handling to ensure I don't swallow control-flow signals.

  61. GLM Assistant

    Let me check for potential circular imports before adding resolveAppPageSpecialError.

  62. GLM Assistant

    No circular import. Let me add the import for resolveAppPageSpecialError and guard against swallowing navigation/control-flow signals.

  63. GLM Assistant

    Now let me update the catch block to re-throw navigation/control-flow signals.

  64. GLM Assistant

    Let me re-run the repro and unit tests to verify the changes.

  65. GLM Assistant

    Let me run a broader set of tests to ensure nothing is broken — the nextjs-compat suite and the production build test.

  66. GLM Assistant

    Let me run the typecheck/lint on the package to ensure the types are correct.

  67. GLM Assistant

    Typecheck passes. Let me run the linter on the modified file.

  68. GLM Assistant

    Let me verify formatting passes on the modified file.

  69. GLM Assistant

    Let me check all callers of renderAppPageErrorBoundary to ensure the change is consistent across all paths.

  70. GLM Assistant

    Let me run the full nextjs-compat test directory (many error-boundary related tests) to be thorough.

  71. GLM Assistant

    Let me double-check there's no onShellError in the SSR path that could swallow the shell error.

  72. GLM Assistant

    No onShellError — shell errors reject and are caught. Let me review the final diff of the source change.

  73. GLM Assistant

    The diff looks good. Now let me clean up the temporary reproduction test and fixture before submitting.

  74. GLM Assistant

    Only the source file is modified. Let me do a final typecheck and lint to confirm everything is clean.

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