This commit is contained in:
Kaustav Mishra 2026-07-14 19:17:07 -07:00 committed by GitHub
commit 389e3a0553
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 0 deletions

View File

@ -1597,6 +1597,11 @@ export class BrowserManager {
// Swap to new browser/context before restoreState (it uses this.context)
const oldBrowser = this.browser;
// Close old pages before clearing the map to release resources
for (const page of this.pages.values()) {
await page.close().catch(() => {});
}
this.context = newContext;
this.browser = newContext.browser();
this.pages.clear();