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

This commit is contained in:
Joel Einbinder 2020-11-16 10:26:34 -08:00 committed by GitHub
parent 3da1f73f1d
commit 31bebc7ea0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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;