From 31bebc7ea001fd6a2a02ebabb6a0e71a1b119177 Mon Sep 17 00:00:00 2001 From: Joel Einbinder Date: Mon, 16 Nov 2020 10:26:34 -0800 Subject: [PATCH] fix(close): allow errors when closing all pages of a context (#4324) --- src/server/page.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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;