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(puppeteer,playwright): Await page close at end of test #487

Closed

Conversation

jpveooys
Copy link
Contributor

Resolves #484

This awaits the page close to resolve the intermittent error at the end of a test suite run mentioned in the linked issue.

The error was observed for Puppeteer, but the same fix is applied here for Playwright in the interest of correctness and consistency.

I'm not aware of any easy way to test for the original error, but all existing tests should be passing.

@CLAassistant
Copy link

CLAassistant commented Mar 25, 2022

CLA assistant check
All committers have signed the CLA.

@jpveooys jpveooys marked this pull request as ready for review March 25, 2022 15:44
@michael-siek michael-siek requested a review from Zidious March 28, 2022 18:55
@Zidious
Copy link
Contributor

Zidious commented Mar 30, 2022

Hey @jpveooys,

Thank you for your contribution, we will review this today

1 similar comment
@Zidious
Copy link
Contributor

Zidious commented Mar 30, 2022

Hey @jpveooys,

Thank you for your contribution, we will review this today

Copy link
Contributor

@Zidious Zidious left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Minor change with regards to the try block

Comment on lines 288 to 296
try {
return await blankPage.evaluate(axeFinishRun, {
partialResults,
options
})
.finally(() => {
blankPage.close();
});
} finally {
await blankPage.close();
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be able to await the blankPage.close() from within the finally block without the use of the try:

return await blankPage
      .evaluate(axeFinishRun, {
        partialResults,
        options
      })
      .finally(async () => {
        await blankPage.close();
      });

Comment on lines 277 to 286
try {
return await blankPage.evaluate(
axeFinishRun,
partialResults as JSONArray,
axeOptions as JSONObject
)
.finally(() => {
blankPage.close();
});
);
} finally {
await blankPage.close();
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here:

  return await blankPage
      .evaluate(
        axeFinishRun,
        partialResults as JSONArray,
        axeOptions as JSONObject
      )
      .finally(async () => {
        await blankPage.close();
      });

This resolves an intermittent 'ProtocolError: Protocol error (Target.closeTarget): Target closed.' error at the end of a test suite run depending on the environment.
In the interest of correctness and to match puppeteer.
@jpveooys jpveooys force-pushed the bugfix/await-browser-close branch from 7b64e99 to 74dbcb5 Compare March 30, 2022 19:39
@jpveooys
Copy link
Contributor Author

Hi @Zidious

I've amended that – though I'd point out the rest of code in those files is using try blocks rather then promise methods, so I'm not sure what the reluctance is here.

Thanks

@jpveooys jpveooys requested a review from Zidious March 30, 2022 19:43
Copy link
Contributor

@Zidious Zidious left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Thank you for contribution @jpveooys!

@Zidious
Copy link
Contributor

Zidious commented Apr 1, 2022

  • reviewed for security

@Zidious
Copy link
Contributor

Zidious commented Apr 1, 2022

Due to circleCI not performing the tests, we will need to cherry pick this PR to get it merged.

@Zidious
Copy link
Contributor

Zidious commented Apr 1, 2022

We have cherry picked this PR and it will be merged soon: #496

Thank you for your contribution @jpveooys!

@jpveooys
Copy link
Contributor Author

jpveooys commented Apr 4, 2022

Hi @Zidious

Okay, thanks – I'll close this one in favour of #496.

@jpveooys jpveooys closed this Apr 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ProtocolError: Protocol error (Target.closeTarget): Target closed.
3 participants