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

fix: micro-suspenses #3013

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

fix: micro-suspenses #3013

wants to merge 1 commit into from

Conversation

tien
Copy link
Contributor

@tien tien commented Mar 6, 2025

Fixes #2848

I honestly don't understand why or how, so would need help with reviewing this. Worth noting this issue only happen with React 19.

Copy link

vercel bot commented Mar 6, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
jotai ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 6, 2025 9:14am

Copy link

codesandbox-ci bot commented Mar 6, 2025

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Copy link

pkg-pr-new bot commented Mar 6, 2025

Open in Stackblitz

More templates

npm i https://pkg.pr.new/jotai@3013

commit: 3ac46b3

@tien tien force-pushed the fix/micro-suspense branch from 4ad0fca to 8dc7120 Compare March 6, 2025 04:38
Copy link

github-actions bot commented Mar 6, 2025

LiveCodes Preview in LiveCodes

Latest commit: 3ac46b3
Last updated: Mar 6, 2025 9:13am (UTC)

Playground Link
React demo https://livecodes.io?x=id/CKNELUEEV

See documentations for usage instructions.

Comment on lines 141 to 149
const value = store.get(atom)
if (isPromiseLike(value)) {
attachPromiseMeta(createContinuablePromise(value))
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it seems to work when we add a microtask delay.

Can we avoid having to add a delay?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per this issue: #2848

Adding a delay is actually a workaround for a React 19 specific bug.

Though when I test around with it, seems like this is the actual part that fix it attachPromiseMeta(createContinuablePromise(value))

Copy link
Member

@dai-shi dai-shi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My gut feeling is that the fix isn't correct. But, I know atomWithObservable is of hacks.
The test should be helpful. I'll check #2848 first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants