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

Improve logic around browser handling #589

Open
josebolos opened this issue Jun 7, 2021 · 0 comments
Open

Improve logic around browser handling #589

josebolos opened this issue Jun 7, 2021 · 0 comments

Comments

@josebolos
Copy link
Member

In the code around the runPa11yTest() function we manage the opening of the headless browser, setting of the different options, loading of the page, and handling of the results. All these steps are currently done sequentially with no error handling in place except for the whole thing being inside a try() block.

While researching #570 I've found several different ways related in which tests can fail during the handling of browser operations:

  • Chrome may fail to launch at all during the setBrowser step, which uses puppeteer.launch().
  • Loading of a specific URL may randomly cause Chrome to crash or close, disconnecting from puppeteer.
  • Chrome may crash or close because it's unable to run in the environment provided. For example, when running on AWS Lambda (which only supports a single process) and --single-process is not passed to puppeteer's args.
  • Chrome may crash at any point during the process for whatever (unknown) reason.

Currently, whenever a problem like this happens, pa11y will just exit with unhelpful error messages shown like (node:26760) UnhandledPromiseRejectionWarning: Error: Page crashed! followed by a stack trace.

I propose to improve the logic around that function, adding some error checking to those function calls so we can handle situations more gracefully, maybe retrying some actions depending on the type of error, and when not possible showing a more meaningful error message.

This would make pa11y more resilient, and less prone to suffer because of bugs in Chrome or puppeteer, and will help us in the future if we add the ability to test more than 1 page at a time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant