Conversation
…3170) Guard account.primaryEmail and hasPassword access in Settings, recover currentAccountUid via URL params or accounts storage scan when missing, and add Sentry diagnostics for future triage.
vbudhram
commented
Mar 3, 2026
| } | ||
|
|
||
| if (!uid) { | ||
| Sentry.captureMessage('setAccountData called with no currentAccountUid', { |
Contributor
Author
There was a problem hiding this comment.
I added some sentry logging here to see how often this happens.
dschom
reviewed
Mar 3, 2026
| await waitFor(() => { | ||
| expect(mockNavigateWithQuery).toHaveBeenCalledWith('/'); | ||
| }); | ||
| warnSpy.mockRestore(); |
Contributor
There was a problem hiding this comment.
Did you want to assert that warn was called?
dschom
reviewed
Mar 3, 2026
| * Used as a recovery path when WKWebView storage eviction loses the UID | ||
| * but account data still exists in the accounts map. | ||
| */ | ||
| export function findActiveAccountUid(): string | null { |
Contributor
There was a problem hiding this comment.
Maybe call it findLastActiveAccountUid()? I feel like that more accurately describes the routine.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Because
This pull request
Issue that this pull request solves
Closes: https://mozilla-hub.atlassian.net/browse/FXA-13170
Checklist
Screenshots (Optional)
Please attach the screenshots of the changes made in case of change in user interface.
Other information (Optional)
yarn startoryarn start mza)http://localhost:3000/settingsTest 1: Missing
currentAccountUid(recovery path)Simulates iOS WKWebView evicting the UID key while account data remains.
Expected: Settings page loads normally.
findActiveAccountUid()recovers the UID from the accounts map and restores it. You can verify recovery by checking:Test 2: Full storage eviction (redirect path)
Simulates complete localStorage loss where no account data can be recovered.
Expected: Graceful redirect to
/(sign-in). Console shows:Before the fix: Page crashes with an unhandled error:
Account data not loaded from localStorage.Test 3: Unit tests