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: check the result when calling js function #17443
Conversation
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.
Nice 👍
@zcbenz this potentially has broken: webContents module getAllWebContents() API returns an array of web contents - returns an array of web contents |
It seems to be a flaky one, the CI is green after restarting. |
Release Notes Persisted
|
I have automatically backported this PR to "5-0-x", please check out #17481 |
* fix: check the result when calling js function * test: should not crash when callback returns nothing
Description of Change
When a JS function returns
undefined
, the returnedv8::MaybeLocal
in C++ would be empty, and callingToLocalChecked()
without checking would crash immediately.This PR does 2 things:
MaybeLocal
is empty before using it;ToLocalChecked
withIsEmpty
where the only purpose is to suppress compiler warning.Checklist
npm test
passesRelease Notes
Notes: Fix crash when passing callbacks which return
undefined
to some APIs.