fix(persist): prevent race condition during concurrent rehydrate calls (#3336)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
* fix(persist): prevent race condition during concurrent rehydrate calls Added hydrationVersion counter to track and invalidate stale hydrations. When multiple rehydrate() calls happen concurrently, only the last one applies its state, preventing race conditions with async storage. - Added hydrationVersion counter incremented on each hydrate() call - Added version checks after each async step (getItem, migrate, set) - Added 3 tests for concurrent rehydration scenarios * fix(persist): refactor simplify hydration abort logic * fix(persist): refactor use consistent comment pattern for abort checks * fix(persist): refactor remove redundant abort checks * fix(persist): refactor remove unnecessary migrationResult check ---------
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Trailers
- Co-authored-by: Daishi Kato <dai-shi@users.noreply.github.com>
Diff stats
2 files+149 added−0 removed
- tests:+132 added−0 removed
- other:+17 added−0 removed