-
-
Notifications
You must be signed in to change notification settings - Fork 33.5k
Description
- Version: v11.10.0
- Platform: Windows 10 64bit
- Subsystem:
napi_make_callback(), like napi_call_function(), takes a recv value to be used as this in JS. Unlike napi_call_function(), however, it validates that the value is of v8 type object, meaning that you can't pass not only NULL, but also explicit JS undefined, global or many other valid(ish) JS this values.
The immediate error on the N-API side looks like it was in from the start in ba7bac5 where a lot of null checking was added: note that napi_call_function() gets lots of checks added, but recv is directly passed through to v8.
I thought this was a bit strange, so I dug in a bit further to see if it was a requirement for node::MakeCallback, and it seems since #14697 the underlying node::MakeCallback() and node::CallbackScope() now also requires recv to not be empty with CHECK(!recv.IsEmpty()) on the line https://github.com/nodejs/node/pull/14697/files#diff-cd53544f44aab2c697bcd7b6a57f23ccR1398 despite the previous code taking care to handle it being null (when not using domains, at least), and the new code not requiring the value as far as I could tell?
Am I missing something obvious?