-
-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add new auto refresh token algorithm (#564)
Adds a new algorithm that automatically refreshes the user's session. Problems with the previous algorithm: - Complex retry logic - Difficult to read and reason about quickly - Used in-memory state while session state is not in memory -- local storage, cookies, etc. - Could produce endless retries - Not multi-tab resilient -- performed refresh from all open tabs at once - Not clock-skew resilient New algorithm: - Runs every 10 seconds (`AUTO_REFRESH_TICK_DURATION`) -- tick - Each tick checks the session from the proper storage medium (not possible to have unsynced state) - If the expiration is within 3 ticks (`AUTO_REFRESH_TICK_THRESHOLD`) a refresh is attempted - If a refresh is not successful, another one will be attempted on the next tick - A failing refresh due to network errors will be retried exponentially but up to a maximum of 10 seconds - Auto refresh runs only on visible tabs, not on hidden tabs Co-authored-by: Joel Lee <[email protected]>
- Loading branch information
Showing
3 changed files
with
189 additions
and
79 deletions.
There are no files selected for viewing
This file contains 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
Oops, something went wrong.