-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure sessions and tokens are synced between tabs #2498
Conversation
{}, | ||
logger.DebugContext.session, | ||
) | ||
logger.warn(`session: clear current account`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sending these to Sentry so we can monitor for spikes
@@ -322,8 +318,8 @@ export function Provider({children}: React.PropsWithChildren<{}>) { | |||
) | |||
|
|||
const logout = React.useCallback<ApiContext['logout']>(async () => { | |||
logger.info(`session: logout`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will be included in any session: clear current account
warnings
@@ -551,41 +547,59 @@ export function Provider({children}: React.PropsWithChildren<{}>) { | |||
return persisted.onUpdate(() => { | |||
const session = persisted.get('session') | |||
|
|||
logger.debug(`session: onUpdate`, {}, logger.DebugContext.session) | |||
logger.info(`session: persisted onUpdate`, {}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sending these to Sentry as breadcrumbs so we know if a broadcast resulted in a logout
setState(s => ({ | ||
...s, | ||
accounts: session.accounts, | ||
currentAccount: session.currentAccount, | ||
})) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't directly access tokens anywhere atm, but I thought it made sense to keep each tab's React state in sync too so we don't surprise ourselves later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Will test by leaving open in my dev env all day
* origin/main: (44 commits) Patch `@lingui/core` to fix `unraw` import resolution error (#2548) 1.65 Fix the fallback to discover behavior on the home feed (#2546) Bump android version code Bump ios build number Add a new home feed-api wrapper and give a header indicating the fallback behavior (#2534) Add accept-language header (#2457) rss: filter out replies server-side (#2518) feat: show muted/blocked status on list card (#2523) 1.64 (#2521) Bump [email protected] (#2519) Create a profile record on new user (#2520) fix: truncate long email address (#2493) fix: set html lang according to app language (#2496) Ensure sessions and tokens are synced between tabs (#2498) package.json: cp --verbose doesn't exist on macos (#2501) Suggest post language correction (#2486) (optional) In app browser (#2490) Toggle minimal shell on any scroll for web (#2499) ✨ New report type, appeal (#2455) ...
This should address the multiple reports of unexpected signouts.
The issue was with users using multiple tabs on web. Both tabs would retain the same
refreshJwt
in memory, and refresh tokens can be used only once. So once a refresh token was rotated in tab A, the tab B was notified but did not update that token on theagent
, and so when tab B tried to get a new access token,refreshSession
would fail.This was a little tricky to pinpoint because if both tabs were periodically reloaded within the access token expiry window, our session handling would pick up the new refresh token from storage and continue as normal for a time. So this issue only existed in long-running multi-tab sessions.