napi-asyncworker-example missing scope
rynz opened this issue · 3 comments
rynz commented
This seems to be the only example that doesn't call:
Napi::HandleScope scope(Env());
Should this example include that too?
gabrielschulhof commented
@rynz actually, it should be the other way around. Node.js ensures that all scopes are present by the time the OnOK
/OnError
callbacks get called. Thanks for noticing the discrepancy!
We have additional documentation here: https://github.com/nodejs/node-addon-api/blob/master/doc/object_lifetime_management.md
rynz commented
@gabrielschulhof thank you!
gotnone commented
Can someone who is more familiar with this than I am check to see if there is still bad example code in node-addon-api/doc/async_worker.md It appears that the OnOK example is using the Napi::HandleScope when it is not necessary.
Thanks