Merge pull request #2257 from PR0M3TH3AN/claude/fix-logout-button-fxhy2

Deduplicate concurrent auth logout calls
This commit is contained in:
thePR0M3TH3AN authored and GitHub committed 2026-02-08 14:31:38 -05:00
commit a54e3c1329
1 file changed
+16 -4
+16 -4
View File
@@ -834,10 +834,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) {
@@ -850,6 +846,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;