Repository navigation
docs(auth): add spec for auth.session.auto_refresh with backoff after failed refreshes - #348
Conversation
… failed refreshes
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review: 1
Please check the settings in the CodeRabbit UI or the
|
…aced session in auto_refresh
| example because the app was closed for longer than the token's lifetime, is | ||
| refreshed within 10 seconds of the load. | ||
|
|
||
| ### After a failed refresh |
There was a problem hiding this comment.
#316 ended up making the refresh settings configurable since there could be different use cases a hard-coded default cannot cover.
Not sure if we want to do the same here? Keeping the values here as a default, but allow them to be configured through the AuthClient.
There was a problem hiding this comment.
I'm not sure if such use-cases exist for the session?
Adds the spec for
auth.session.auto_refresh: when the background loop refreshes, how it backs off after a failed refresh, and how the app and the platform lifecycle start and stop it.This PR is stacked on #316, since it builds on
refresh_session.md,get_session.md, andretry_options.mdfrom that PR. #316 defines a single refresh, including its own retries within a 30 second deadline. This spec defines the loop that starts those refreshes.Why
Without a defined cadence, every SDK picks its own. When a project's
/tokenendpoint keeps failing, for example a broken auth hook answering 500, some SDKs send a failing refresh every few seconds per device, indefinitely. One project with a broken token endpoint produced about 1 million failing requests a day from a few hundred devices.What the spec defines
exp, three times the 30 second safety margin, so a refresh and its retries finish before Get Session has to refresh on its own. A refresh is never due sooner than half the token's lifetime (expminusiat) after this instance received the session from the server, which stops refresh storms with short-lived tokens or a device clock running ahead. The loop starts a due refresh within 10 seconds, so either a timer or a periodic tick works.Retry-Afterhonoured up to the cap. A steady 5xx costs a device about one request a minute once the wait reaches its cap.get_session.mdandrefresh_session.mdfrom #316 now link to the new spec instead of naming the capability ID.Linear: SDK-2947