-
-
Notifications
You must be signed in to change notification settings - Fork 622
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
[Bug] atom state not found in flush undefined (introduced in 0.16.11) #517
Comments
Thanks for reporting. The fix in v0.16.11 is very important. Here's the diff. diff --git a/src/core/vanilla.ts b/src/core/vanilla.ts
index 699c731..9ee10a4 100644
--- a/src/core/vanilla.ts
+++ b/src/core/vanilla.ts
@@ -596,7 +596,9 @@ const commitAtomState = <Value>(
}
export const flushPending = (state: State): void => {
- state.p.forEach((prevDependencies, atom) => {
+ const pending = [...state.p]
+ state.p.clear()
+ pending.forEach(([atom, prevDependencies]) => {
const atomState = getAtomState(state, atom)
if (atomState) {
if (prevDependencies) {
@@ -611,7 +613,6 @@ export const flushPending = (state: State): void => {
const mounted = state.m.get(atom)
mounted?.l.forEach((listener) => listener())
})
- state.p.clear()
}
export const subscribeAtom = ( I assume the problem is caused by creating an array from map iterator. OK, I think I get it. The cjs build: The esm build: |
Can you try the codesandbox build in #518 and see if it fixes your issue? |
I can't test my app in a codesandbox, but I can try to update to v1.0.0 in a few |
This worked, thank you, v1.0.0 does not trigger the aforementioned errors. |
Cool! and what a relief. By "try codesandbox build", I mean you can install the build with https://ci.codesandbox.io/status/pmndrs/jotai/pr/518/builds/139548 It's a bit hard to find the link and the instructions. 😕 |
This bug happens again for me, when updating from 2.6.5 to 2.7.0 (or 2.8.0).
|
I'm not sure if it's related with the original issue, but what you observe can be probably caused by #2396. |
I managed to create a minimal reproduction and started a new discussion for that #2494 |
I had been using 0.16.7 for a while, and decided to upgrade my dependencies tonight.
This updated my app to 0.16.11, where Jotai started failing left and right for me with multiple errors popping up in the console:
I reverted back to 0.16.7 and started climbing the release versions to isolate the culprit.
0.16.10 still works fine for me... it seems 0.16.11 is problematic in my situation.
Let me know if you need more details.
The text was updated successfully, but these errors were encountered: