Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 task done
AustynDing opened this issue Mar 6, 2025 · 0 comments
Open
1 task done
Labels

Comments

@AustynDing
Copy link

  • 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants