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(driver): add check to make sure Runtime.evaluate result exists #6089

Merged
merged 7 commits into from
Sep 24, 2018
21 changes: 15 additions & 6 deletions lighthouse-core/gather/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,15 +311,24 @@ class Driver {
contextId,
};

this.sendCommand('Runtime.evaluate', evaluationParams).then(result => {
this.sendCommand('Runtime.evaluate', evaluationParams).then(response => {
clearTimeout(asyncTimeout);
const value = result.result.value;

if (result.exceptionDetails) {
if (response.exceptionDetails) {
// An error occurred before we could even create a Promise, should be *very* rare
reject(new Error('an unexpected driver error occurred'));
} if (value && value.__failedInBrowser) {
reject(Object.assign(new Error(), value));
return reject(new Error('an unexpected driver error occurred'));
Copy link
Member

Choose a reason for hiding this comment

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

let's change this text. how about this?

`Evaluation exception: ${response.exceptionDetails.text}`

}

// Protocol should always return a 'result' object, but it is sometimes undefined
Copy link
Member

Choose a reason for hiding this comment

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

...undefined. See #6026

// see https://github.com/GoogleChrome/lighthouse/issues/6026
if (response.result === undefined) {
return reject(new Error('Driver did not sent a result object'));
Copy link
Member

Choose a reason for hiding this comment

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

Runtime.evaluate response omits a result

}

const value = response.result.value;

if (value && value.__failedInBrowser) {
return reject(Object.assign(new Error(), value));
} else {
resolve(value);
}
Expand Down