Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

fix(close): allow errors when closing all pages of a context (#4324)

Joel Einbinder31bebc7ea001
diff --git a/src/server/page.ts b/src/server/page.ts
index 672e08509b..192a6c7b30 100644
--- a/src/server/page.ts
+++ b/src/server/page.ts
@@ -409,7 +409,9 @@ export class Page extends EventEmitter {
if (this._closedState !== 'closing') {
this._closedState = 'closing';
assert(!this._disconnected, 'Protocol error: Connection closed. Most likely the page has been closed.');
- await this._delegate.closePage(runBeforeUnload);
+ // This might throw if the browser context containing the page closes
+ // while we are trying to close the page.
+ await this._delegate.closePage(runBeforeUnload).catch(e => debugLogger.log('error', e));
}
if (!runBeforeUnload)
await this._closedPromise;