8000 Bug: `use` function doesn't warn about uncached promise when promise doesn't resolve immediately · Issue #31790 · facebook/react · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Bug: use function doesn't warn about uncached promise when promise doesn't resolve immediately #31790

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

Open
tomdohnal opened this issue Dec 15, 2024 · 4 comments
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug

Comments

@tomdohnal
Copy link

When I pass an uncached promise that doesn't resolve immediately to the use function, (e. g. use(new Promise(resolve => setTimeout(resolve, 1000)))), I don't get the "A component was suspended by an uncached promise. Creating promises inside a Client Component or hook is not yet supported, except via a Suspense-compatible library or framework." warning.

Instead, I get into an infinite loop as the Promise keeps getting recreated.

(When I use a promise that gets resolved immediately, like use(new Promise(resolve => resolve()), I do get the warning message as expected)

React version: ^19.0.0

Steps To Reproduce

  1. Go to https://codesandbox.io/p/sandbox/modest-merkle-cr7qcn
  2. Open the preview and devtools
  3. See there's no warning message about an uncached promise
  4. See that the "hi from Promise" gets logged indefinitely

Link to code example:
https://codesandbox.io/p/sandbox/modest-merkle-cr7qcn

The current behavior

No warning message gets logged

The expected behavior

I get the "A component was suspended by an uncached promise. Creating promises inside a Client Component or hook is not yet supported, except via a Suspense-compatible library or framework." warning regardless of how long the promise passed to the use function takes to resolve.

@tomdohnal tomdohnal added the Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug label Dec 15, 2024
@OhFlohre
Copy link

Same here

@khanghoang
Copy link

I'm experiencing the same issue with v19.0.0. It works fine with the version used in React's doc (link to codesandbox)

@ctnelson1997
Copy link

Same issue. Great way to DOS yourself :)

@mmarcmartins
Copy link

Same, instead i'm get the error: An unknown Component is an async Client Component. Only Server Components can be async at the moment. This error is often caused by accidentally adding 'use client' to a module that was originally written for the server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug
Projects
None yet
Development

No branches or pull requests

5 participants
0