From ce676c5cc0d88c61a485ad860c7dd0bca8834cb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E7=94=B5=E8=8A=BD=E8=A1=A3?= Date: Thu, 16 Apr 2026 22:59:19 -0400 Subject: [PATCH] fix(browser): prevent duplicate concurrent login launches per account (P1-14) --- src/main/ipc-browser-handlers.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/ipc-browser-handlers.ts b/src/main/ipc-browser-handlers.ts index 48322601..cdc0b7d8 100644 --- a/src/main/ipc-browser-handlers.ts +++ b/src/main/ipc-browser-handlers.ts @@ -8,6 +8,8 @@ import { } from "@shared/contracts"; import { fail, ok, type RegisterDomainHandlersDependencies } from "./ipc-domain-common"; +const inflightBrowserLogins = new Set(); + export function registerBrowserHandlers({ registerHandle, db, @@ -89,6 +91,10 @@ export function registerBrowserHandlers({ return fail("ACCOUNT_NOT_FOUND", "Social account not found"); } + if (inflightBrowserLogins.has(input.socialAccountId)) { + return fail("LOGIN_IN_PROGRESS", "A login for this account is already in progress."); + } + inflightBrowserLogins.add(input.socialAccountId); browserActions.launchLoginBrowser(input.socialAccountId, account.platform).then(async (result) => { if (result.success) { const latestAccount = db.getSocialAccount(input.socialAccountId, account.companyId); @@ -119,6 +125,8 @@ export function registerBrowserHandlers({ } }).catch((error) => { logger.error(`[browser] Login failed: ${error}`); + }).finally(() => { + inflightBrowserLogins.delete(input.socialAccountId); }); return ok(true);