persist with AsyncStorage race condition? #2092
Unanswered
hanrelan
asked this question in
Bug report
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi -
I'm wondering if there's a race condition with zustand persist using AsyncStorage as a backend. Specifically, I don't think that AsyncStorage guarantees that if you do:
That the final result will be 2. The first call could take longer than the second to complete and have 1 as the result.
If that's the case (this is hard to create a repro for so is mostly a theoretical concern), then I think the way persist calls AsyncStorage (at the end of every state update) would result in saved state being out-of-date.
Not an expert so not sure if that's true, but if it is, would something like this be necessary for it to work properly?
Beta Was this translation helpful? Give feedback.
All reactions