-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Conversation
// Also occurs when the expression is not valid JavaScript. | ||
const errorMessage = response.exceptionDetails.exception ? | ||
response.exceptionDetails.exception.description : | ||
response.exceptionDetails.text; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this 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}' } } }
// Also occurs when the expression is not valid JavaScript. | ||
const errorMessage = response.exceptionDetails.exception ? | ||
response.exceptionDetails.exception.description : | ||
response.exceptionDetails.text; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
extracted from #9605 / #9650
repro by messing up the expression:
before:
after: