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(store2): "stuck" derived atoms where some derivations may never resolve #2448

Merged
merged 5 commits into from
May 27, 2024

Conversation

backbone87
Copy link
Contributor

Just a failing test case for:
When an async derived atom picks up a dep asynchronously that never resolves, the derivation never settles even when a subsequent update of the dep does resolve.

I added another test case that demonstrates that picking up the dep synchronously does not lead to this issue

Copy link

vercel bot commented Mar 12, 2024

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 May 26, 2024 4:19am

Copy link

codesandbox-ci bot commented Mar 12, 2024

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

github-actions bot commented Mar 12, 2024

LiveCodes Preview in LiveCodes

Latest commit: cfd7b88
Last updated: May 26, 2024 4:18am (UTC)

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

See documentations for usage instructions.

@dai-shi
Copy link
Member

dai-shi commented Mar 12, 2024

Is it even fixable? Feel free to try.

@backbone87
Copy link
Contributor Author

the problem is that async deps are only recognized by store once the derivation settles. imho all deps should be recognized and tracked as soon as they occur. a consistent read would also be nice, e.g.

async (get) => {
  const a = get(anAtom);
  await delay(someTime);
  assert(a === get(anAtom));
}

@dai-shi
Copy link
Member

dai-shi commented Mar 12, 2024

that's kind of by design: collect deps once in sync and once when settled. it's a computational task, and so it might require some tricks to cover more cases.
So, I'd say, it's currently a design limitation.

@dai-shi dai-shi marked this pull request as draft March 29, 2024 12:19
@dai-shi dai-shi changed the title failing test case for "stuck" derived atoms where some derivations may never resolve fix(store2): "stuck" derived atoms where some derivations may never resolve May 26, 2024
@dai-shi dai-shi marked this pull request as ready for review May 26, 2024 06:15
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.

Thanks for the nice tests. The "sync" version actually reveals a bug in store2.ts.

@dai-shi dai-shi added this to the v2.8.2 milestone May 26, 2024
@dai-shi dai-shi merged commit 0a5a16b into pmndrs:main May 27, 2024
37 checks passed
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.

2 participants