Bug: `use` function doesn't warn about uncached promise when promise doesn't resolve immediately
tomdohnal opened this issue · 1 comments
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
- Go to https://codesandbox.io/p/sandbox/modest-merkle-cr7qcn
- Open the preview and devtools
- See there's no warning message about an uncached promise
- 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.
Same here