docs(settings): Correct JwtTokenCache storage comment - #20962
Open
nshirley wants to merge 1 commit into
Open
Conversation
Because: * The comment claimed JWTs are held in page memory, but they are backed by local storage and intentionally persist across refreshes. This commit: * Describes `static state` as a write-through cache of local storage.
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the JwtTokenCache doc comment in fxa-settings to better describe how MFA JWTs are stored and cached, aligning documentation with the cache’s actual persistence model.
Changes:
- Rewrites the
JwtTokenCachecomment to describe local-storage-backed persistence across refreshes/navigations. - Clarifies that
static stateacts as an in-memory cache hydrated from persistent storage and written-through on mutations.
Comment on lines
+257
to
+259
| * Tokens are backed by local storage so they survive hard navigates and page | ||
| * refreshes. `static state` is an in-memory cache of that stored value; it is | ||
| * lazily hydrated on first read and written through on every mutation. |
vbudhram
approved these changes
Aug 4, 2026
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
JwtTokenCachestated that MFA JWTs "will be held in page memory" and would not survive hard navigates. That is not how the class behaves: the tokens are backed by local storage and intentionally persist across page refreshes.static statefor session storage "if edge cases arise," which would undo deliberate behavior that test infrastructure already relies on.This pull request
JwtTokenCachedoc comment inpackages/fxa-settings/src/lib/cache.tsto state that tokens are backed by local storage and survive hard navigates and refreshes.static stateas what it actually is: an in-memory cache of the stored value, lazily hydrated on first read and written through on every mutation.No behavior change — comment only.
Issue that this pull request solves
Closes: N/A
Checklist
Put an
xin the boxes that applyHow to review (Optional)
Other information (Optional)
No Jira ticket — comment-only correction with no behavior change.
Supporting evidence for the corrected wording:
cache.ts:15builds the store viaStorage.factory('localStorage'), which resolves tonew Storage(win.localStorage)(storage.ts:160-161).statesetter (cache.ts:287-290) callsstorage.set(...), andsetToken/removeToken/clearTokensall reassignstate, so every mutation is written through.packages/functional-tests/lib/testAccountTracker.ts:666-690reads and writeslocalStorage['__fxa_storage.mfa_token_cache']directly, so cross-navigation persistence is already depended upon.