napi_make_callback() with null async_context doesn't reuse current context #35188
Labels
addons
Issues and PRs related to native addons.
async_hooks
Issues and PRs related to the async hooks subsystem.
node-api
Issues and PRs related to the Node-API.
What steps will reproduce the bug?
Call back sync to javascript from native using
napi_make_callback()
withasync_context
set toNULL
.The simplest way to reproduce this is to add following code in test/node-api/test_make_callback_recurse/test.js
According to docs I would expect the test to pass as they tell
However NULL is also allowed, which indicates the current async context (if any) is to be used for the callback.
.How often does it reproduce? Is there a required condition?
Always
What is the expected behavior?
I would expect that the current async id is not changed.
What do you see instead?
async_id 0 is used
Additional information
I'm not sure here if the docs should be corrected or the implementation.
Maybe we should even disallow to pass
NULL
tonapi_make_callback()
.Relevant place in source:
node/src/node_api.cc
Lines 732 to 734 in 9d12c14
Please note also that the c++ NAPI wrapper uses
NULL
as default argument forMakeCallback
(see https://github.com/nodejs/node-addon-api/blob/6562e6b0ab604fd55b9c2d0cf954c9ce93e4bdee/napi.h#L1056-L1065).The text was updated successfully, but these errors were encountered: