Skip to content

Report and log RSC loader, action and middleware errors by default - #15598

Merged
brophdawg11 merged 5 commits into
mainfrom
brooks/rsc-log-server-errors
Nov 23, 2026
Merged

brophdawg11 merged 5 commits into
mainfrom
brooks/rsc-log-server-errors

Conversation

@brookslybrand

Copy link
Copy Markdown
Contributor

This change makes RSC server error reporting match non-RSC Framework Mode, so errors from loaders, actions and middleware are no longer silently swallowed.

  • Loader, action and middleware errors in staticContext.errors are now passed to matchRSCServerRequest's onError. The filter is the same as handleDocumentRequest in non-RSC mode: thrown Responses and data() are skipped, and internal error responses such as 404s are reported. Before this, onError only received server function, resource route and CSRF errors, even though its JSDoc says it's called with "any errors that occur during the request processing".
  • When no onError is provided, errors are logged with console.error, skipping aborted requests. This matches the default handleError in non-RSC mode. The default RSC Framework entry doesn't pass onError, so apps on the default entries had no server-side logging for any of these errors.

Errors thrown while rendering, in server components or in client components during SSR, still aren't reported. Non-RSC mode logs these through entry.server.tsx. They need separate handling (for example, server function errors could be double-reported through the RSC payload, and routeRSCServerRequest has no onError option), so they're left for a follow-up.

@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Preview Build Available

Preview builds have been created for this PR. You can install react-router using:

pnpm install "remix-run/react-router#preview/pr-15598&path:packages/react-router"

And/or install other packages via:

pnpm install "remix-run/react-router#preview/pr-15598&path:packages/react-router-dev"
pnpm install "remix-run/react-router#preview/pr-15598&path:packages/react-router-express"
pnpm install "remix-run/react-router#preview/pr-15598&path:packages/react-router-node"
pnpm install "remix-run/react-router#preview/pr-15598&path:packages/react-router-serve"

These preview builds will be updated automatically as you push new commits.

@brookslybrand
brookslybrand force-pushed the brooks/rsc-log-server-errors branch from 867267b to 2a146b4 Compare October 20, 2026 20:47
@brophdawg11 brophdawg11 self-assigned this Nov 3, 2026
Report middleware errors after form actions have consumed the POST body. Avoid reporting route errors again when the built-in RSC Framework root boundary renders on the server.
@brophdawg11

Copy link
Copy Markdown
Contributor

I found one middleware error path that still bypassed onError. If a route action reads request.formData() and middleware throws after await next(), the retry tries to clone the consumed POST body. The request then rejects with a body-cloning error before onError receives the original middleware error.

I pushed 683008db4 to resolve the conflict with main and run submission preparation only once. The commit also removes duplicate SSR logging from the built-in RSC Framework root boundary while preserving logging for render errors. The focused Jest and Chromium integration tests passed.

Authored by an AI agent on behalf of @brophdawg11

@brophdawg11

Copy link
Copy Markdown
Contributor

The council review found a duplicate log in RSC Data mode. When a loader throws on a document request and the root has no custom error boundary, unstable_matchRSCServerRequest logs the error, then the default Data Router boundary logs it again during SSR in development. The existing guard covered the built-in RSC Framework boundary.

I pushed 7e901039b so both default boundaries use the same guard. The RSC Data regression test went from two log calls to one, and the existing SSR test still verifies that the boundary logs a new render error. I also moved the change note to the unstable section. The full Jest suite and all four RSC logging integration tests passed locally.

Authored by an AI agent on behalf of @brophdawg11

@brophdawg11 brophdawg11 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The council approved this head. The updated branch preserves the POST-body retry fix and avoids duplicate SSR error logs in both RSC modes. Node 22 and 24 checks passed.

Authored by an AI agent on behalf of @brophdawg11

@brophdawg11
brophdawg11 merged commit 74f2193 into main Nov 23, 2026
12 checks passed
@brophdawg11
brophdawg11 deleted the brooks/rsc-log-server-errors branch November 23, 2026 20:41
@github-actions

Copy link
Copy Markdown
Contributor

The preview branch preview/pr-15598 has been deleted now that this PR is merged/closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants