Skip to content

Commit 0a847ca

Browse files
FlarnaMylesBorins
authored andcommitted
doc: update napi_make_callback documentation
Calling napi_make_callback() with no async_context is not resulting in using the current async context instead an empty context (id 0) is used. Using NULL is like using node::Makecallback without async_context which is deprecated since Node.js 10 (DEP0099). PR-URL: #35321 Fixes: #35188 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Michael Dawson <midawson@redhat.com>
1 parent a8d3a7f commit 0a847ca

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

doc/api/n-api.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5176,9 +5176,11 @@ NAPI_EXTERN napi_status napi_make_callback(napi_env env,
51765176
* `[in] env`: The environment that the API is invoked under.
51775177
* `[in] async_context`: Context for the async operation that is
51785178
invoking the callback. This should normally be a value previously
5179-
obtained from [`napi_async_init`][]. However `NULL` is also allowed,
5180-
which indicates the current async context (if any) is to be used
5181-
for the callback.
5179+
obtained from [`napi_async_init`][].
5180+
In order to retain ABI compatibility with previous versions, passing `NULL`
5181+
for `async_context` will not result in an error. However, this will result
5182+
in incorrect operation of async hooks. Potential issues include loss of
5183+
async context when using the `AsyncLocalStorage` API.
51825184
* `[in] recv`: The `this` object passed to the called function.
51835185
* `[in] func`: `napi_value` representing the JavaScript function to be invoked.
51845186
* `[in] argc`: The count of elements in the `argv` array.

0 commit comments

Comments
 (0)