fix(browser-manager): await login-window close during shutdown

This commit is contained in:
ZacharyZhang-NY committed 2026-04-16 23:04:29 -04:00
1 parent 3bdc8b4be1
commit 4fd1326089
3 files changed
+17 -5

No files matched your search

+14 -2
View File
@@ -300,10 +300,22 @@ export class BrowserManager {
}
}
shutdown() {
async shutdown() {
// Wait for each pending window-close to finish so any callers that chain
// `await shutdown()` before recreating the manager don't observe torn
// state (half-closed login windows still holding a partition).
const closePromises: Promise<void>[] = [];
for (const [, win] of this.loginWindows) {
if (!win.isDestroyed()) win.close();
if (!win.isDestroyed()) {
closePromises.push(
new Promise<void>((resolve) => {
win.once("closed", () => resolve());
win.close();
}),
);
}
}
await Promise.all(closePromises);
this.loginWindows.clear();
this.activeActionWindows.clear();
this.cancelledActionIds.clear();