Skip to content

Suspense behavior differs between React and Preact when using throw promise #4719

Open
@AustynDing

Description

@AustynDing
  • Check if updating to the latest Preact version resolves the issue

Describe the bug
Preact's Suspense boundary does not maintain state synchronization or properly handle Promise resolution compared to React. When a component throws a Promise within a Suspense boundary:
React smoothly transitions from fallback to resolved content and continues propagating state updates (e.g., active state changes are logged).
Preact stops propagating state updates (e.g., active logs disappear after the first throw), and fails to transition back to resolved content.
This discrepancy prevents Preact from supporting dynamic UI transitions (e.g., loading states) that rely on Suspense with thrown Promises.

To Reproduce

  1. Open React example: https://stackblitz.com/edit/vitejs-vite-zbtfqxzc?file=src%2FApp.tsx
    • Toggle the button to observe:
      • Proper fallback/nofallback transitions
      • Console logs showing active state changes during throws
  2. Open Preact example: https://stackblitz.com/edit/create-preact-starter-oemy1da4?file=src%2Findex.jsx
    • Toggle the button to observe:
    • Console logs stop showing active state changes after the first throw

Expected Behavior:
Like React, Preact should:

  1. Maintain state propagation (show active state changes in console)
  2. Transition smoothly from fallback to normal content when resolving the thrown promise

Actual Behavior:
Preact:

  1. Stops propagating state changes (active state logs disappear after first throw)
  2. Fails to transition back to normal content

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions