From 47fdad0ef2264f07e25b23369c787e81c7f0fd23 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 8 Feb 2026 19:09:50 +0000 Subject: [PATCH] Fix logout button not actually logging out the user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- js/app/authSessionCoordinator.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/js/app/authSessionCoordinator.js b/js/app/authSessionCoordinator.js index 31431b9c..189f1394 100644 --- a/js/app/authSessionCoordinator.js +++ b/js/app/authSessionCoordinator.js @@ -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;