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

misc: handle connection errors even before the timeout #8583

Merged
merged 3 commits into from
Apr 24, 2019
Merged
Show file tree
Hide file tree
Changes from 2 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
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
17 changes: 9 additions & 8 deletions lighthouse-core/gather/connections/cri.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,17 @@ class CriConnection extends Connection {
});
});

request.setTimeout(CONNECT_TIMEOUT, () => {
request.abort();
let ignoreECONNRESET = false;
patrickhulce marked this conversation as resolved.
Show resolved Hide resolved
request.on('error', err => {
// @ts-ignore - not in @types yet. See https://nodejs.org/api/errors.html#errors_class_systemerror.
if (err.code === 'ECONNRESET' && ignoreECONNRESET) return;
reject(err);
});

request.setTimeout(CONNECT_TIMEOUT, () => {
// 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;
}
});
ignoreECONNRESET = true;
request.abort();

// Reject on error with code specifically indicating timeout in connection setup.
const err = new LighthouseError(LighthouseError.errors.CRI_TIMEOUT);
Expand Down