Skip to content

Document errorInfo.errorBoundary in onCaughtError - #8750

Open
cbasdev wants to merge 1 commit into
reactjs:mainfrom
cbasdev:docs/oncaughterror-errorboundary
Open

cbasdev wants to merge 1 commit into
reactjs:mainfrom
cbasdev:docs/oncaughterror-errorboundary

Conversation

@cbasdev

@cbasdev cbasdev commented Nov 10, 2026 •

Copy link
Copy Markdown

The createRoot and hydrateRoot reference pages say that onCaughtError receives an errorInfo object containing only the componentStack. React also passes errorInfo.errorBoundary: the instance of the Error Boundary that caught the error.

This field has been passed since onCaughtError was introduced in react/react#28641 (React 19). See ReactFiberErrorLogger.js:

onCaughtError(error, {
  componentStack: errorInfo.stack,
  errorBoundary:
    boundary.tag === ClassComponent
      ? boundary.stateNode // This should always be the case as long as we only have class boundaries
      : null,
});

Without this, readers of the reference have no way to know that onCaughtError can tell which Error Boundary handled the error, for example to tag error reports by boundary.

This PR mentions errorBoundary in the onCaughtError option description and in the "Error logging in production" section of both pages. The code example, code blocks, and <CodeStep> highlighting are unchanged.

Test plan

Ran against published react@19.3.1 and react-dom@19.3.1 on Node 26.13.0 (jsdom), rendering a class Error Boundary around a component that throws, with an onCaughtError callback passed to createRoot:

react-dom version: 19.3.1
error.message: boom
errorInfo keys: [ 'componentStack', 'errorBoundary' ]
typeof componentStack: string
errorBoundary instanceof Boundary: true
errorBoundary === rendered instance (after commit): true

yarn lint, yarn tsc, yarn lint-heading-ids, yarn deadlinks and git diff --check pass.

🤖 Generated with Claude Code

React passes the Error Boundary instance that caught the error as
errorInfo.errorBoundary to onCaughtError (since react#28641), but the
createRoot and hydrateRoot docs only mentioned componentStack.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Size changes

Details

📦 Next.js Bundle Analysis for react-dev

This analysis was generated by the Next.js Bundle Analysis action. 🤖

This PR introduced no changes to the JavaScript bundle! 🙌

@cbasdev cbasdev changed the title Document errorInfo.errorBoundary in onCaughtError Document errorInfo.errorBoundary in onCaughtError Nov 10, 2026

This branch was successfully deployed

1 active deployment
Preview — faab19d0 Deployed Nov 10, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant