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(core): update atom value with conditional dependencies (regression with #2363) #2534

Merged
merged 9 commits into from
May 21, 2024

Conversation

probeiuscorp
Copy link
Contributor

Related Issues or Discussions

Fixes #2532

Summary

Add missing test case for conditional dependents receiving stale values since 59e04ab.

Check List

  • yarn run prettier for formatting code and docs

Copy link

vercel bot commented Apr 30, 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 21, 2024 1:54pm

Copy link

codesandbox-ci bot commented Apr 30, 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.

@dai-shi
Copy link
Member

dai-shi commented Apr 30, 2024

Add missing test case for conditional dependents receiving stale values since 59e04ab.

So, it's a regression in #2363 and v2.6.4.

Copy link

github-actions bot commented Apr 30, 2024

LiveCodes Preview in LiveCodes

Latest commit: 7194200
Last updated: May 21, 2024 1:53pm (UTC)

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

See documentations for usage instructions.

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 working on it.

Hm, the skipIf hack doesn't work for build test. Let me see if I can find a better way.

store.sub(filteredAtom, () => undefined)
store.sub(stageAtom, () => undefined)

store.set(dataAtom, [100])
Copy link
Member

Choose a reason for hiding this comment

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

Do we need this here, or can use simply initialize the data atom with [100]?
If we need it here, please add a comment for clarification.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought it was important, but yeah the test still works without it.

@dai-shi
Copy link
Member

dai-shi commented Apr 30, 2024

oops, #2535 wasn't enough...

hmm, is it really failing?

@dai-shi
Copy link
Member

dai-shi commented May 1, 2024

Hi @samkline, if you are around, can you check this and see if you can fix store.ts?

@dai-shi dai-shi marked this pull request as draft May 5, 2024 02:02
@dai-shi
Copy link
Member

dai-shi commented May 15, 2024

We need to fix this...

@probeiuscorp
Copy link
Contributor Author

I did some investigating and I believe the regression involves force in readAtomState.

2534-regression-diagnostics
(text contents of image)

  • Column 1 is the test results before the regression (off of 2a25f03)
  • Column 2 is the test results after the regression (off of 1d7e6e3)
  • Column 3 is the test results after monkey-patching column 2's force to match column 1

My understanding is that force is the cause of this regression. Before the regression, in this test case, readAtomState is called with a force of undefined then true and then undefined but after the regression readAtomState is called with a force of undefined then undefined and then true. As demonstrated in column 3, simply changing force to match the old way seems to fix the regression.

(the test code)

@dai-shi
Copy link
Member

dai-shi commented May 19, 2024

I did some investigating and I believe the regression involves force in readAtomState.

Nice finding.

simply changing force to match the old way seems to fix the regression.

I didn't follow everything. So, what's the suggested change?

@probeiuscorp
Copy link
Contributor Author

Sorry, it was a debugging change I made just for the test case (these lines) to learn whether force played a part in the regression. I don't have any code changes for production to fix the bug.

@dai-shi dai-shi changed the title Add tests for stale dependents fix(core): update atom value with conditional dependencies (regression with #2363) May 21, 2024
@dai-shi dai-shi marked this pull request as ready for review May 21, 2024 02:23
@dai-shi dai-shi added this to the v2.8.1 milestone May 21, 2024
@dai-shi dai-shi merged commit 0319cd4 into pmndrs:main May 21, 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.

Possible regression of 2.6.4 with derived atoms
2 participants