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): fix error handling for Runtime.evaluate #9831

Merged
merged 1 commit into from
Oct 14, 2019

Conversation

connorjclark
Copy link
Collaborator

extracted from #9605 / #9650

repro by messing up the expression:

image

before:

image

after:

image

// Also occurs when the expression is not valid JavaScript.
const errorMessage = response.exceptionDetails.exception ?
response.exceptionDetails.exception.description :
response.exceptionDetails.text;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i'm not confident enough in the protocol to know if we can remove response.exceptionDetails.text so i keep it as fallback

Copy link
Member

Choose a reason for hiding this comment

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

puppeteer has a more robust version https://github.com/GoogleChrome/puppeteer/blob/e0c8d46af1ce2c063778b66aa29c4c00ab8aeba5/lib/helper.js#L47-L60

but i'm happy with the improvement you've made here

Copy link
Member

@paulirish paulirish left a comment

Choose a reason for hiding this comment

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

fwiw here's one of these payloads

{ result: 
   { type: 'object',
     subtype: 'error',
     className: 'ReferenceError',
     description: 'ReferenceError: chrome is not defined\n    at <anonymous>:1:1',
     objectId: '{"injectedScriptId":1,"id":1}' },
  exceptionDetails: 
   { exceptionId: 1,
     text: 'Uncaught',
     lineNumber: 0,
     columnNumber: 0,
     scriptId: '30',
     exception: 
      { type: 'object',
        subtype: 'error',
        className: 'ReferenceError',
        description: 'ReferenceError: chrome is not defined\n    at <anonymous>:1:1',
        objectId: '{"injectedScriptId":1,"id":2}' } } } 

via cyrus-and/chrome-remote-interface#51

// Also occurs when the expression is not valid JavaScript.
const errorMessage = response.exceptionDetails.exception ?
response.exceptionDetails.exception.description :
response.exceptionDetails.text;
Copy link
Member

Choose a reason for hiding this comment

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

puppeteer has a more robust version https://github.com/GoogleChrome/puppeteer/blob/e0c8d46af1ce2c063778b66aa29c4c00ab8aeba5/lib/helper.js#L47-L60

but i'm happy with the improvement you've made here

Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants