Flush pending approval popups on address switch
Some checks failed
check / check (push) Failing after 13s

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.
This commit is contained in:
2026-02-26 04:02:33 +07:00
parent e847f27243
commit dce561464d

View File

@@ -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] || [] : [];