-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
fix(page): dispatch errors into page #3550
fix(page): dispatch errors into page #3550
Conversation
Errors thrown on the node side of the `page.exposeFunction` callback should be dispatched into the page. Fixes puppeteer#3549
lib/Page.js
Outdated
} | ||
|
||
function deliverError(name, seq, message, stack) { | ||
let error = new Error(message); |
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.
Const
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.
Done.
lib/Page.js
Outdated
error = e; | ||
} | ||
let expression = null; | ||
if (error) |
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.
Things can throw null. Instead of checking if there is an error, do the logic in the catch.
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.
Fair. Creepy, but fair.
window[name]['callbacks'].delete(seq); | ||
} | ||
|
||
function deliverError(name, seq, message, stack) { |
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.
nit: JSDoc
oh, we should probably pass the name as well. For TimeoutErrors |
@@ -428,7 +428,7 @@ class Page extends EventEmitter { | |||
} | |||
const seq = (me['lastSeq'] || 0) + 1; | |||
me['lastSeq'] = seq; | |||
const promise = new Promise(fulfill => callbacks.set(seq, fulfill)); |
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.
Ok
Errors thrown on the node side of the
page.exposeFunction
callbackshould be dispatched into the page.
Fixes #3549