Page MenuHomePhabricator

[web] Move getSafariEncryptionKey to initPromise
ClosedPublic

Authored by michal on Nov 7 2023, 12:23 AM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Dec 20, 5:47 PM
Unknown Object (File)
Sun, Dec 15, 5:51 PM
Unknown Object (File)
Sun, Dec 15, 5:51 PM
Unknown Object (File)
Sun, Dec 15, 5:51 PM
Unknown Object (File)
Sun, Dec 15, 5:51 PM
Unknown Object (File)
Sun, Dec 15, 5:49 PM
Unknown Object (File)
Sun, Dec 15, 5:28 PM
Unknown Object (File)
Sat, Dec 14, 3:44 PM
Subscribers

Details

Summary

ENG-5670

Webapp on safari didn't correctly initialize the database and so rehydration failed. Because cookies are now stored in redux it also meant that the user was logged out.
The problem was that the async call to getSafariEncryptionKey (which only happens on safari) wasn't in this.initPromise. That meant we could end up in a situation where this.status is INIT_IN_PROGRESS but initPromise is undefined. This broke logic in isDatabaseSupported which assumed that these two variables would be always in sync.

Test Plan

Added logs to DatabaseModule.isDatabaseSupported and commReduxStorageEngine.getItem (which tries to get data from sqlite and internally calls isDatabaseSupported)
Without changes in this diff:

  • Reloaded the website
  • From logs in isDatabaseSupported we can see that
    • this.status is INIT_IN_PROGRESS which is correct
    • But this.initPromise in undefined
  • isDatabaseSupported call in getItem returns false and rehydration fails
  • User is logged out

With changes:

  • Reloaded the website
  • Now this.initPromise contains a pending promise
  • isDatabaseSupported call in getItem returns true
  • User is remains logged in

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Harbormaster returned this revision to the author for changes because remote builds failed.Nov 7 2023, 12:39 AM
Harbormaster failed remote builds in B23828: Diff 32844!
michal requested review of this revision.Nov 7 2023, 1:12 AM

Additionaly link the init in progress status to the init promise with types, so we won't get this situation in the future (an async operation between setting the status and setting the init promise).

tomek added inline comments.
web/database/database-module-provider.js
32–34 ↗(On Diff #32845)

Can this be readonly?

This revision is now accepted and ready to land.Nov 7 2023, 1:57 AM