Skip to content

Improve logout handling and concurrent login detection#1733

Open
paustint wants to merge 1 commit into
mainfrom
bug/fix-desktop-logout-race
Open

Improve logout handling and concurrent login detection#1733
paustint wants to merge 1 commit into
mainfrom
bug/fix-desktop-logout-race

Conversation

@paustint
Copy link
Copy Markdown
Contributor

Enhance the IPC service to better manage logout processes and detect concurrent logins. This update prevents issues where a logout could inadvertently restore an old authentication state, ensuring a smoother user experience.

Copilot AI review requested due to automatic review settings May 17, 2026 18:48
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Jetstream Desktop IPC auth flow to avoid race conditions where an in-flight auth verification could accidentally restore (or overwrite) authentication state during logout or a concurrent login.

Changes:

  • Coalesce concurrent logout calls via a shared inFlightLogout promise and expose “logout-in-flight” state to auth checking.
  • Harden checkAuth against concurrent logout/login by re-reading persisted app data before mutating it and bailing out when state has changed.
  • Avoid clearing a valid cached session on transport/network failures during auth verification.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

// A concurrent login replaced the token; the auth error was for the old token —
// leave the newer session intact and surface it to the caller.
return latestAppData.userProfile
? { userProfile: latestAppData.userProfile, authInfo: { deviceId, accessToken: latestAppData.accessToken } }
// token we received was issued for the OLD login, so do not write it. Surface
// the newer session to the caller instead.
return latestAppData.userProfile
? { userProfile: latestAppData.userProfile, authInfo: { deviceId, accessToken: latestAppData.accessToken } }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants