Flush pending approval popups on address switch
Some checks failed
check / check (push) Failing after 13s
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:
@@ -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] || [] : [];
|
||||
|
||||
Reference in New Issue
Block a user