fix(persist): clearStorage() should invalidate concurrent async rehydration (#3555)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
* fix(persist): advance hydrationVersion in clearStorage to prevent stale async hydration Addresses https://github.com/pmndrs/zustand/discussions/3554 When clearStorage() is called while an async rehydrate() is still pending, the storage item gets removed but the older read can finish afterward and apply the value that was just cleared. Fix: increment hydrationVersion in clearStorage() so any in-flight hydration is treated as stale and discarded, consistent with how concurrent rehydrate() calls are already handled. Co-authored-by: dai-shi <490574+dai-shi@users.noreply.github.com> * fix: correct import order in persistAsync.test.tsx Co-authored-by: dai-shi <490574+dai-shi@users.noreply.github.com> * chore: remove package-lock.json (project uses pnpm) Co-authored-by: dai-shi <490574+dai-shi@users.noreply.github.com> ---------
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Trailers
- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
- Co-authored-by: dai-shi <490574+dai-shi@users.noreply.github.com>
- Co-authored-by: Daishi Kato <dai-shi@users.noreply.github.com>
Diff stats
2 files+180 added−0 removed
- tests:+179 added−0 removed
- other:+1 added−0 removed