Skip to content

Commit

Permalink
cli: always handle chrome connection errors (#8583)
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickhulce authored and brendankenny committed Apr 24, 2019
1 parent 36214ab commit 90ae485
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ before_script:
# see comment above about puppeteer
- export CHROME_PATH="$(which google-chrome-stable)"
- sh -e /etc/init.d/xvfb start
- google-chrome-stable --version
- yarn build-all
script:
- yarn bundlesize
Expand Down
16 changes: 6 additions & 10 deletions lighthouse-core/gather/connections/cri.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,21 +108,17 @@ class CriConnection extends Connection {
});
});

request.setTimeout(CONNECT_TIMEOUT, () => {
request.abort();

// After aborting, we expect an ECONNRESET error. Ignore.
request.on('error', err => {
// @ts-ignore - not in @types yet. See https://nodejs.org/api/errors.html#errors_class_systemerror.
if (err.code !== 'ECONNRESET') {
throw err;
}
});
// This error handler is critical to ensuring Lighthouse exits cleanly even when Chrome crashes.
// See https://github.com/GoogleChrome/lighthouse/pull/8583.
request.on('error', reject);

request.setTimeout(CONNECT_TIMEOUT, () => {
// Reject on error with code specifically indicating timeout in connection setup.
const err = new LighthouseError(LighthouseError.errors.CRI_TIMEOUT);
log.error('CriConnection', err.friendlyMessage);
reject(err);

request.abort();
});
});
}
Expand Down

0 comments on commit 90ae485

Please sign in to comment.