Skip to content

Commit

Permalink
core(driver): fix error handling for Runtime.evaluate (#9831)
Browse files Browse the repository at this point in the history
  • Loading branch information
connorjclark authored and paulirish committed Nov 6, 2019
1 parent 8b88e94 commit d80d29e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lighthouse-core/gather/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -528,8 +528,12 @@ class Driver {
this.setNextProtocolTimeout(timeout);
const response = await this.sendCommand('Runtime.evaluate', evaluationParams);
if (response.exceptionDetails) {
// An error occurred before we could even create a Promise, should be *very* rare
return Promise.reject(new Error(`Evaluation exception: ${response.exceptionDetails.text}`));
// An error occurred before we could even create a Promise, should be *very* rare.
// Also occurs when the expression is not valid JavaScript.
const errorMessage = response.exceptionDetails.exception ?
response.exceptionDetails.exception.description :
response.exceptionDetails.text;
return Promise.reject(new Error(`Evaluation exception: ${errorMessage}`));
}
// Protocol should always return a 'result' object, but it is sometimes undefined. See #6026.
if (response.result === undefined) {
Expand Down

0 comments on commit d80d29e

Please sign in to comment.