Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: do not report errored pages after context closure #4346

Merged
merged 1 commit into from
Nov 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/server/browserContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,10 @@ export abstract class BrowserContext extends EventEmitter {
await this._doUpdateRequestInterception();
}

isClosingOrClosed() {
return this._closedStatus !== 'open';
}

async close() {
if (this._closedStatus === 'open') {
this._closedStatus = 'closing';
Expand Down
7 changes: 6 additions & 1 deletion src/server/chromium/crBrowser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,13 @@ export class CRBrowser extends Browser {
this._crPages.set(targetInfo.targetId, crPage);
crPage.pageOrError().then(pageOrError => {
const page = crPage._page;
if (pageOrError instanceof Error)
if (pageOrError instanceof Error) {
// Initialization error could have happened because of
// context/browser closure. Just ignore the page.
if (context!.isClosingOrClosed())
return;
page._setIsError();
}
context!.emit(BrowserContext.Events.Page, page);
if (opener) {
opener.pageOrError().then(openerPage => {
Expand Down
7 changes: 6 additions & 1 deletion src/server/firefox/ffBrowser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,13 @@ export class FFBrowser extends Browser {

ffPage.pageOrError().then(async pageOrError => {
const page = ffPage._page;
if (pageOrError instanceof Error)
if (pageOrError instanceof Error) {
// Initialization error could have happened because of
// context/browser closure. Just ignore the page.
if (context.isClosingOrClosed())
return;
page._setIsError();
}
context.emit(BrowserContext.Events.Page, page);
if (!opener)
return;
Expand Down
7 changes: 6 additions & 1 deletion src/server/webkit/wkBrowser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,13 @@ export class WKBrowser extends Browser {

wkPage.pageOrError().then(async pageOrError => {
const page = wkPage._page;
if (pageOrError instanceof Error)
if (pageOrError instanceof Error) {
// Initialization error could have happened because of
// context/browser closure. Just ignore the page.
if (context!.isClosingOrClosed())
return;
page._setIsError();
}
context!.emit(BrowserContext.Events.Page, page);
if (!opener)
return;
Expand Down