fix(cluster): sign out of the cluster when signing out of an instance#1411
fix(cluster): sign out of the cluster when signing out of an instance#1411dawsontoth wants to merge 2 commits into
Conversation
Signing out of an instance invalidates the session on that node, but the cluster stayed flagged as signed in — so the next cluster request could be load-balanced onto the logged-out node and fail with 'Must login' (#1320). Instance sign-out (row button and context menu) now also clears the cluster's local auth state — potentially-authenticated flag, stored basic auth, Fabric Connect flag and in-memory token — via a new authStore.signOutLocally(). Sibling instances hold their own sessions and stay signed in. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request introduces a helper function signOutOfInstance to sign out of a single instance and locally sign out of its cluster, preventing load-balancing routing issues to logged-out nodes. It also adds corresponding unit tests and updates the UI components to use this new helper. The reviewer recommends ensuring that local state and credentials are cleared unconditionally (using a try...finally block) even if the server-side logout API request fails, and updating the unit tests to reflect this behavior.
A failed logout request must not leave stale flags or credentials behind in localStorage — swallow the server error and clear the instance's and cluster's local auth state regardless, matching ClusterHome's onDisconnect. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
kriszyp
left a comment
There was a problem hiding this comment.
Approving — signing out of an instance now also clears the local cluster auth state (closing the lingering-cluster-session-after-logout gap), correctly scoped so it doesn't drop other still-connected instances, and well-tested. Thanks @dawsontoth!
— 🤖 KrAIs (Kris's review assistant)
Fixes #1320
Problem
Signing out of an instance invalidates the session on that node, but Studio kept the cluster flagged as signed in (
Studio:PotentiallyAuthenticated). The cluster FQDN load-balances across the same nodes, so the next cluster request could land on the logged-out node and fail with a "Must login" error — nondeterministically, depending on the FQDN and instance count.Fix
Instance sign-out (both the row's "Direct Sign Out" button in
InstanceLogInCelland the context/"…" menu inuseInstanceMenuItems) now goes through a sharedsignOutOfInstance()helper that, after the server-side logout:authStore.signOutLocally()— the potentially-authenticated flag, stored basic-auth credentials, the Fabric Connect flag, and its in-memory token.Sibling instances hold their own sessions and are deliberately left signed in, per the issue.
This mirrors the existing inverse behavior: cluster sign-out already flags all of its instances as signed out (
ClusterCard), and cluster sign-in flags them all as signed in (useClusterInstanceSignIn).Testing
signOutOfInstance.test.tscovers: instance + cluster signed out while a sibling instance stays signed in; cluster credentials/Fabric Connect flags cleared; local state preserved when the server-side logout fails.tsc -b, oxlint, and dprint.authStorethrough the new helper: the persisted auth map drops the cluster and the signed-out instance, keeps the sibling.🤖 Generated with Claude Code