persist clearStorage can be followed by stale async hydration #3554
Bug DescriptionWith async storage,
Reproduction Link |
Replies: 2 comments 4 replies
|
Confirmed, this is a real race, and your diagnosis is exactly right. Walking through
So with async storage the interleaving is:
The one-line fix is to make clearStorage: () => {
++hydrationVersion // invalidate any in-flight rehydrate
storage?.removeItem(options.name)
},After that, any hydration that was already running hits its next Two notes: this only affects async storage, since with synchronous storage the |
Thanks! Could you check #3555?