HomePhabricator
Diffusion Comm 06cb756f0bae

[web/lib/keyserver] avoid out of sync `updatesCurrentAsOf` between client and…

Description

[web/lib/keyserver] avoid out of sync updatesCurrentAsOf between client and keyserver

Summary:
This is fix to issue described in: ENG-5906.

In D9948 I started to persist updatesCurrentAsOf.
I also updated setInitialReduxState action to rely on rehydrated data when it's a staff user.
What I missed is updating currentAsOfPromise, which for updatesCurrentAsOf was using server time here.
This means that after reloading the app, the client (staff) has its own updatesCurrentAsOf from the previously received update (previous session) while the keyserver has newer updatesCurrentAsOf created while returning the initial state version.
This causes this condition to be true, and as a result was causing FULL_STATE_SYNC here which on prod kills the socket because of the amount of data to transfer.

This diff should make updatesCurrentAsOf synced between client and server.

This also fixes issue described here. Previously, when updatesCurrentAsOf was just started to be persisted, it gets rehydrated with undefined/0 value, this means after loading app all updates were started to be fetched. Right now if updatesCurrentAsOf is 0 we fetch everything in InitialReduxStateResponder and set updatesCurrentAsOf as serverTime.

This is only for staff, for standard users everything should work as previously.

Test Plan:

  1. Reload app and make sure that there is no FULL_STATE_SYNC.
  2. Make sure updates work properly.
  3. Make sure updatesCurrentAsOf has correct value.
  4. Make sure policies logic (which is related to updatesCurrentAsOf value) works.

Reviewers: inka, tomek, michal

Reviewed By: inka, michal

Subscribers: ashoat

Differential Revision: https://phab.comm.dev/D10070