Async atoms dependent on sync atoms sometimes behave as if mounted when pending #3124
Replies: 3 comments 12 replies
-
|
|
Beta Was this translation helpful? Give feedback.
-
|
Maybe this would resolve the concern: #3125 |
Beta Was this translation helpful? Give feedback.
-
|
Sorry, late to the party. Sounds like we are hitting a tricky situation. I'm fine to drop some existing tests if we agree that the fix is more appropriate.
I'm not sure if it helps though.
The reason we don't mount a new promise while pending is to avoid memory leaks. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Bug Description
I believe this issue is connected to
getMountedOrPendingDependents(), the one with a// TODO(daishi): revisit this implementationremark.It's used in
recomputeInvalidatedAtomsand here is how it works now on a totally unmounted atom set: it searches for parents of changed atoms that are pending (none are mounted) and triggers their updates.I would expect it to behave without any regard to pending statuses at all, just as a sync version would: to only trigger a dependant if it's mounted.
Not sure if it was intentional, but ignoring the pending dependants in
recomputeInvalidatedAtomsindeed breaks some tests such asdependency.test.tsx > refreshes deps for each async read. But frankly, the broken tests' logic seems dubious itself:atom(get => get(syncDep))Reproduction Link
https://stackblitz.com/edit/node-3bhhnxpm?file=index.test.ts&terminal=test
Beta Was this translation helpful? Give feedback.
All reactions