Skip to content

Commit

Permalink
Retry launching browser if first time fails
Browse files Browse the repository at this point in the history
This is a first attempt at fixing #128. It's unlikely to fix the issue completely, or even at all, as the browser will sometimes crash after testing several URLs and we don't have any logic to reopen a browser that has crashed mid-tests.
  • Loading branch information
josebolos committed May 24, 2021
1 parent 6846233 commit fd1a491
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions lib/pa11y-ci.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,20 @@ module.exports.defaults = {
function pa11yCi(urls, options) {
return new Promise(async resolve => {
// Create a test browser to assign to tests
const testBrowser = await puppeteer.launch(options.chromeLaunchConfig);
let testBrowser;

// Issue #128: on specific URLs, puppeteer will sometimes fail to load
// with a bunch of different, unhelpful errors. This will reattempt to
// relaunch the browser once before bailing out
try {
testBrowser = await puppeteer.launch(
options.chromeLaunchConfig
);
} catch (error) {
testBrowser = await puppeteer.launch(
options.chromeLaunchConfig
);
}

// Default the passed in options
options = defaults({}, options, module.exports.defaults);
Expand All @@ -52,7 +65,6 @@ function pa11yCi(urls, options) {
const log = options.log;
delete options.log;


// Create a Pa11y test function and an async queue
const taskQueue = queue(testRunner, options.concurrency);
taskQueue.drain = testRunComplete;
Expand Down

0 comments on commit fd1a491

Please sign in to comment.