From dce561464dbc65ba24cd74e125d39822695190e6 Mon Sep 17 00:00:00 2001 From: sneak Date: Thu, 26 Feb 2026 04:02:33 +0700 Subject: [PATCH] Flush pending approval popups on address switch When switching addresses, reject and close any open approval popup windows so their promises don't hang forever. Without this, stale pending approvals from automatic dapp reconnection attempts block future connection requests. --- src/background/index.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/background/index.js b/src/background/index.js index 799bf73..46314e7 100644 --- a/src/background/index.js +++ b/src/background/index.js @@ -336,6 +336,18 @@ async function broadcastAccountsChanged() { for (const key of Object.keys(connectedSites)) { delete connectedSites[key]; } + // Reject and close any pending approval popups so they don't hang + for (const [id, approval] of Object.entries(pendingApprovals)) { + approval.resolve({ approved: false, remember: false }); + if (approval.windowId) { + windowsApi.remove(approval.windowId, () => { + if (runtime.lastError) { + // window already closed + } + }); + } + delete pendingApprovals[id]; + } const s = await getState(); const activeAddress = await getActiveAddress(); const allowed = activeAddress ? s.allowedSites[activeAddress] || [] : [];