Skip to content

Commit cf88ed8

Browse files
mhdawsoncodebytere
authored andcommitted
doc: update napi_async_init documentation
Fixes: #33153 Change documentation to make async_resource required as opposed to optional in napi-async_init. Changes over time mean this parameter is required for proper operation of async hooks (which are still experimental). This changes the documentation to document what callers should do. We are doing this only in the doc in order to avoid a breaking change in N-API. We could create a new version of the method for which the parametrer is enforced as mandatory but we should only do that once async hooks is no longer experimental. In that case we could deprecate (but not remove this version of the method). Signed-off-by: Michael Dawson <[email protected]> PR-URL: #33181 Reviewed-By: Gerhard Stöbich <[email protected]> Reviewed-By: Chengzhong Wu <[email protected]>
1 parent 25443fa commit cf88ed8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

doc/api/n-api.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -4672,8 +4672,13 @@ napi_status napi_async_init(napi_env env,
46724672
```
46734673

46744674
* `[in] env`: The environment that the API is invoked under.
4675-
* `[in] async_resource`: An optional object associated with the async work
4675+
* `[in] async_resource`: Object associated with the async work
46764676
that will be passed to possible `async_hooks` [`init` hooks][].
4677+
In order to retain ABI compatibility with previous versions,
4678+
passing `NULL` for `async_resource` will not result in an error, however,
4679+
this will result incorrect operation of async hooks for the
4680+
napi_async_context created. Potential issues include
4681+
loss of async context when using the AsyncLocalStorage API.
46774682
* `[in] async_resource_name`: Identifier for the kind of resource
46784683
that is being provided for diagnostic information exposed by the
46794684
`async_hooks` API.

0 commit comments

Comments
 (0)