Open Bug 1866365 Opened 1 year ago Updated 1 year ago

Introduce callbacks for an updated profile in firefox accounts

Categories

(Application Services :: Fxa Client, enhancement, P3)

enhancement

Tracking

(Not tracked)

People

(Reporter: markh, Unassigned)

References

(Blocks 1 open bug)

Details

From github: https://github.com/mozilla/application-services/issues/5328.

We currently cache profile data in our state, see https://github.com/mozilla/application-services/blob/280d69389689a17fac7b9d324338e83fec447fc1/components/fxa-client/src/internal/state_persistence.rs#L108

We also give the cache a 2-minute TTL, in order to not overwhelm the FxA server. See https://github.com/mozilla/application-services/blob/280d69389689a17fac7b9d324338e83fec447fc1/components/fxa-client/src/internal/profile.rs#L41

However, in the case our consumer has no network connection, the consumer would retrieve from cache for 2 minutes and thus getting last cached profile data, before suddenly experiencing no profile data. The reason is:

  • When first running the app, the get_profile API correctly recognizes that it has been less than 2 minutes since the profile data was last cached, and thus returns from cache. So we see profile data
  • After two minutes, the get_profile API would invalidate the cache, and attempt a network request, which would fail with an error. This leads the app to now think there is no profile, when there might be one

If we'd like to fix this, we can introduce a new refresh_profile API, that works hand in hand with a new callback interface to notify the app of an updated profile. The refresh_profile wouldn't return anything and instead just trigger the callback when:

  • it reads the cache
  • if it went to the network, when it receives a new value from the network

#5333 is a demo, but instead of re-using the existing "get_profile" function, we should introduce a new refresh_profile function (or update_profile_if_needed maybe a better name)

┆Issue is synchronized with this Jira Task
┆Epic: Moving fxa-client functionality out of android-components

Change performed by the Move to Bugzilla add-on.

Assignee: nobody → bdeankawamura
Blocks: 1867795
Status: NEW → ASSIGNED
Assignee: bdeankawamura → nobody
Status: ASSIGNED → NEW
You need to log in before you can comment on or make changes to this bug.