Skip to content

Bug: Errors thrown from "hidden" Activity boundaries shouldn't escape the boundary #35073

@ztanner

Description

@ztanner

The provided repro is a contrived example, but a common example of where this is unexpected is if you were using Activity to render a previously visited page, and that page rendered a hook that throws an error if it's missing some sort of context.

In the case of Next.js, imagine we're grabbing route params via useParams, and we navigate to a route that no longer has that param available. When that subtree is switched to "hidden" mode, if any of the containing hooks/components threw an error when a param value is unavailable, that error would be triggered when navigating to the different page.

React version: 19.2.0

Steps To Reproduce

  1. Render an <Activity> boundary in "hidden" mode, and have it throw an error
  2. Observe that even though the containing component is hidden, the error escapes and causes an error while rendering the "Visible" element.

Link to code example: https://codesandbox.io/p/devbox/distracted-poitras-yd3dkt

The current behavior

Throwing an error inside of a "hidden" Activity boundary triggers an error.

The expected behavior

Throwing an error inside of a "hidden" Activity boundary should only trigger the error when the boundary is visible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: UnconfirmedA potential issue that we haven't yet confirmed as a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions