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

core(gather): define new DNS failure LH Error #6579

Merged
merged 7 commits into from
Nov 16, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 6 additions & 2 deletions lighthouse-core/gather/gather-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,12 @@ class GatherRunner {
if (!mainRecord) {
errorDef = LHError.errors.NO_DOCUMENT_REQUEST;
} else if (mainRecord.failed) {
errorDef = {...LHError.errors.FAILED_DOCUMENT_REQUEST};
errorDef.message += ` ${mainRecord.localizedFailDescription}.`;
if (mainRecord.localizedFailDescription === 'net::ERR_NAME_NOT_RESOLVED') {
errorDef = {...LHError.errors.DNS_FAILURE};
Copy link
Member

Choose a reason for hiding this comment

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

if no string/message altering, no need to object spread to get a copy (e.g. see NO_DOCUMENT_REQUEST above)

} else {
Copy link
Member

Choose a reason for hiding this comment

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

these conditionals are multiplying in an unseemly fashion. Maybe #6457 can take on cleaning them up with early returns @exterkamp

errorDef = {...LHError.errors.FAILED_DOCUMENT_REQUEST};
errorDef.message += ` ${mainRecord.localizedFailDescription}.`;
}
} else if (mainRecord.hasErrorStatusCode()) {
errorDef = {...LHError.errors.ERRORED_DOCUMENT_REQUEST};
errorDef.message += ` Status code: ${mainRecord.statusCode}.`;
Expand Down
7 changes: 7 additions & 0 deletions lighthouse-core/lib/lh-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,13 @@ const ERRORS = {
lhrRuntimeError: true,
},

// Protocol timeout failures
DNS_FAILURE: {
Copy link
Collaborator

Choose a reason for hiding this comment

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

proto update :)

code: 'DNS_FAILURE',
message: strings.dnsFailure,
lhrRuntimeError: true,
},

// Hey! When adding a new error type, update lighthouse-result.proto too.
};

Expand Down
1 change: 1 addition & 0 deletions lighthouse-core/lib/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ module.exports = {
requestContentTimeout: 'Fetching resource content has exceeded the allotted time',
urlInvalid: `The URL you have provided appears to be invalid.`,
protocolTimeout: `Waiting for DevTools protocol response has exceeded the allotted time.`,
dnsFailure: `DNS servers could not resolve the provided domain.`,
};