Fix logout button not actually logging out the user

The auth:logout event listener in applicationBootstrap.js fires
synchronously during authService.logout(), setting __handled = true and
starting handleAuthLogout as fire-and-forget. When requestLogout() then
checked detail.__handled, it saw true and returned early — before
applyLoggedOutUiState() could update the UI.

Two changes fix this:

1. Remove the __handled early-return guard from requestLogout() so it
   always awaits handleAuthLogout.

2. Add a promise-based dedup guard to handleAuthLogout so the event
   listener's fire-and-forget call and requestLogout's awaited call
   share a single execution instead of running the logout cleanup twice.

https://claude.ai/code/session_01ArpiYU9bNdzme5xBHWnKuS
This commit is contained in:
Claude committed 2026-02-08 19:09:50 +00:00
1 parent 88227bd4ce
commit 47fdad0ef2
1 file changed
+16 -4
+16 -4
View File
@@ -516,10 +516,6 @@ export function createAuthSessionCoordinator(deps) {
const detail = await this.authService.logout();
if (detail && typeof detail === "object") {
if (detail.__handled === true) {
return detail;
}
try {
detail.__handled = true;
} catch (error) {
@@ -532,6 +528,22 @@ export function createAuthSessionCoordinator(deps) {
},
async handleAuthLogout(detail = {}) {
// Deduplicate concurrent calls — the auth:logout event listener may
// fire-and-forget this method while requestLogout() also awaits it.
// Return the in-flight promise so both callers resolve together.
if (this._pendingLogoutPromise) {
return this._pendingLogoutPromise;
}
this._pendingLogoutPromise = this._executeAuthLogout(detail);
try {
return await this._pendingLogoutPromise;
} finally {
this._pendingLogoutPromise = null;
}
},
async _executeAuthLogout(detail = {}) {
if (detail && typeof detail === "object") {
try {
detail.__handled = true;