-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auth/PM-7811 - Refactor User Auto Unlock Key Hydration Process To Remove Race Conditions #8979
Conversation
…emove active account listening logic as it introduced race conditions with user key memory retrieval happening before the user auto unlock key was set into memory.
… if there is an active account, then set the user key in memory from the user auto unlock key.
… key in memory if the auto unlock key is set on account switch and background init (must act on all accounts so that account switcher displays unlock status properly).
…to unlock key is set on init
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8979 +/- ##
==========================================
- Coverage 27.70% 27.70% -0.01%
==========================================
Files 2392 2392
Lines 69356 69368 +12
Branches 12934 12938 +4
==========================================
- Hits 19218 19215 -3
- Misses 48658 48673 +15
Partials 1480 1480 ☔ View full report in Codecov by Sentry. |
No New Or Fixed Issues Found |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one question
apps/browser/src/auth/popup/account-switching/services/account-switcher.service.ts
Outdated
Show resolved
Hide resolved
…ove Race Conditions (#8979) * PM-7811 - Refactor UserKeyInitService to UserAutoUnlockKeyService - remove active account listening logic as it introduced race conditions with user key memory retrieval happening before the user auto unlock key was set into memory. * PM-7811 - CLI - (1) Fix deps (2) On CLI init (pre command execution), if there is an active account, then set the user key in memory from the user auto unlock key. * PM-7811 - Browser Extension / desktop - (1) Update deps (2) Sets user key in memory if the auto unlock key is set on account switch and background init (must act on all accounts so that account switcher displays unlock status properly). * PM-7811 - Web - (1) Update deps (2) Sets user key in memory if the auto unlock key is set on init * PM-7811 - Fix account switcher service changes not being necessary.
Type of change
Objective
To resolve PM-7811 which initially presented itself as the CLI not properly unlocking after exporting a session key on a fresh install or after deleting
data.json
. During our investigation, we realized there was a cross client race condition with any code that called to check if the user had a user key in memory and theUserKeyInitService's
listener for setting the user key in memory if the user auto unlock key was set. This refactor should eliminate any chances of race conditions and ensure that the user key in memory is always set as early as possible in the client initialization processes.Code changes
UserKeyInitService
toUserAutoUnlockKeyService
as it is now purely involved with managing the user auto unlock key.UserAutoUnlockKeyService
dependenciesuserAutoUnlockKeyService.setUserKeyInMemoryIfAutoUserKeySet
on Web client init for singular active accountuserAutoUnlockKeyService.setUserKeyInMemoryIfAutoUserKeySet
on Desktop client init for n accounts (desktop supports account switching)userAutoUnlockKeyService.setUserKeyInMemoryIfAutoUserKeySet
on Browser Extension client init for n accounts (browser extension supports account switching)userAutoUnlockKeyService.setUserKeyInMemoryIfAutoUserKeySet
on CLI client init for singular active account which executes pre-command execution.Screenshots
Web
PM-7811.-.Web.-.never.lock.works.mov
CLI
Desktop
PM-7811.-.Desktop.-.never.lock.works.on.init.and.for.account.switch.mov
Browser Extension
PM-7811.-.Browser.Extension.-.never.lock.works.on.init.and.for.account.switch.mov
Before you submit