Skip to content

Bug: SuspenseList revealOrder="together" and error boundaries #18429

@eps1lon

Description

@eps1lon

React version: 0.0.0-experimental-aae83a4b9

Steps To Reproduce

  1. Wrap and error boundary around a suspense boundary inside a <SuspenseList revealOrder="together" />
  2. Crash with Cannot read property 'shared' of null

Link to code example:

https://codesandbox.io/s/quirky-cannon-e4t1c is forked from https://codesandbox.io/s/black-wind-byilt

The current behavior

The following code causes the described crash:

<SuspenseList revealOrder="together">
  <ErrorBoundary fallback={null}>
    <Suspense fallback={<h2>Loading posts...</h2>}>
      <ProfileTimeline resource={resource} />
    </Suspense>
  </ErrorBoundary>
  <Suspense fallback={<h2>Loading fun facts...</h2>}>
    <ProfileTrivia resource={resource} />
  </Suspense>
</SuspenseList>

revealOrder="forwards" does not crash as well as placing the error boundary inside the suspense boundary like so:

<SuspenseList revealOrder="together">
  <Suspense fallback={<h2>Loading posts...</h2>}>
    <ErrorBoundary fallback={null}>
      <ProfileTimeline resource={resource} />
    </ErrorBoundary>
  </Suspense>
  <Suspense fallback={<h2>Loading fun facts...</h2>}>
    <ProfileTrivia resource={resource} />
  </Suspense>
</SuspenseList>

The expected behavior

The position of the ErrorBoundary is likely wrong in the first place (since I can move it around to not cause a crash while preserving the semantics I expect). Maybe this needs a descriptive warning/error why this is happening and how I should resolve it?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions