Page MenuHomePhabricator

[lib] avoid modifying state on rehydrate action
AbandonedPublic

Authored by kamil on Feb 2 2024, 3:07 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Nov 23, 2:53 PM
Unknown Object (File)
Sat, Nov 23, 12:23 PM
Unknown Object (File)
Wed, Nov 6, 8:05 PM
Unknown Object (File)
Oct 15 2024, 12:01 PM
Unknown Object (File)
Oct 15 2024, 12:00 PM
Unknown Object (File)
Oct 15 2024, 12:00 PM
Unknown Object (File)
Sep 28 2024, 11:50 AM
Unknown Object (File)
Sep 4 2024, 7:54 AM
Subscribers

Details

Reviewers
inka
Summary

According to docs: "Auto merge means if the some piece of substate was modified by your reducer during the REHYDRATE action, it will skip this piece of state." src.

If the logic changes and we modify keyserverStore state on persist/REHYDRATE it could cause skipping the rehydrated state.

Test Plan

Add this line
keyserverStore = { ...keyserverStore }; in if - previously it was causing logging out on each refresh, now it shouldn't

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

kamil held this revision as a draft.
kamil published this revision for review.Feb 2 2024, 3:29 AM
inka requested changes to this revision.Feb 5 2024, 1:57 AM

I don't understand the point of this diff. Do we need to do keyserverStore = { ...keyserverStore }; for some reason?
I know what mechanism you mean, with the REHYDRATE skipping a part of state if it was changed by the reducer, but this code should never change anything on REHYDRATE action, because keyserverStore is not changed by the REHYDRATE action. So the inner ifs (line 102 and 115) will always return false and not execute. And it is very intentional that the keyserver store is not changed on the REHYDRATE action.

If the logic changes and we modify keyserverStore state on persist/REHYDRATE it could cause skipping the rehydrated state.

If the logic changes and we modify keyserverStore state on persist/REHYDRATE the rehydration WILL be skipped for the keyserver store, REGARDELESS of this code here. On the other hand, if we decide to change keyserverStore on REHYDRATE action, then maybe this code should run? Are we sure it shouldn't?

This revision now requires changes to proceed.Feb 5 2024, 1:57 AM

Discussed this with @inka today in the office - we think this code is confusing but adding action.type !== rehydrateActionType is not making it any better.