question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

New atom invalidation logic is incorrect

See original GitHub issue

Hi, we recently upgraded Jotai in our app from 1.7.0 to 1.8.2. This was a great performance improvement for our app, but we’ve found a subtle bug that sometimes causes useAtomValue to return old/stale values. We’re using React 17.0.2 without Suspense and can reproduce it on both our web app and React Native app.

In particular, we have many usages of useAtomValue for the same derived atom, and some instances return the correct, current value while other instances are “stuck” returning the old, stale value.

Unfortunately I don’t have a simple reproduction, as our application is quite complex with a large tree of primitive and derived atoms, and we can only reproduce this when performing some complex operations that update many of those atoms.

However, I’ve noticed that when commenting out these lines: https://github.com/pmndrs/jotai/blob/fc96b2c72a057cb00afef0dfbe2ca30cbb7b23c4/src/core/store.ts#L866-L875 we get correct behavior, but we also get extra re-renders, and of course Jotai’s ‘no extra rerenders after commit with derived atoms (#1213)’ optimization test fails.

I’ll keep digging to see if I can identify the cause or a simple reproduction case, but wanted to raise this issue in case the cause is obvious to one of the maintainers.

Thanks!

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:2
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
dai-shicommented, Nov 4, 2022

It’s known as dual package hazard, and we know this library suffers from it. We spent lots of efforts previously, but at the moment, we think to leave the problem. (as we didn’t find reasonable solutions that work well for us.)

Hope you can configure your env to only use one bundle. Would also love to see a minimal reproduction. Please open a new discussion.

0reactions
edongashicommented, Nov 4, 2022

Thank you @dai-shi for the pointer. Posted a description and potential fix in #1537. Sorry for hijacking the thread.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Russell's Logical Atomism
Bertrand Russell (1872–1970) described his philosophy as a kind of “logical atomism”, by which he meant to endorse both a metaphysical view ...
Read more >
www.cs.bham.ac.uk/research/projects/poplog/fixed/p...
File: C.all/lib/lib/logic.p > Purpose: Teaching propositional logic ... true; if atom(input) then logic_error('incomplete formula') endif else false endif; ...
Read more >
Detect, Correct, Retract: How to manage incorrect structural ...
In contrast to small-molecule crystallography, the macromolecular electron density maps are rarely at atomic resolution, are sometimes of ...
Read more >
Top 10 Most Common C++ Mistakes That Developers Make
Common Mistake #1: Using “new” and ”delete” Pairs Incorrectly ... It uses atomic operations for increasing/decreasing a reference counter, so it is thread ......
Read more >
x86 MESI invalidate cache line latency issue - Stack Overflow
Or if ProcessD is running on the other logical core of the same physical ... at the start of a cache line. alignas(64)...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found