Skip to content

Commit df0f7a3

Browse files
mhdawsontargos
authored andcommitted
doc: clarify async execute callback usage
Clarify that calls to N-API should be avoided in the 'execute' callback. PR-URL: #21217 Refs: nodejs/help#1318 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Vse Mozhet Byt <[email protected]>
1 parent 521f8f1 commit df0f7a3

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

doc/api/n-api.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,11 @@ operations. Callback functions must statisfy the following signature:
179179
typedef void (*napi_async_execute_callback)(napi_env env, void* data);
180180
```
181181

182+
Implementations of this type of function should avoid making any N-API calls
183+
that could result in the execution of JavaScript or interaction with
184+
JavaScript objects. Most often, any code that needs to make N-API
185+
calls should be made in `napi_async_complete_callback` instead.
186+
182187
#### napi_async_complete_callback
183188
Function pointer used with functions that support asynchronous
184189
operations. Callback functions must statisfy the following signature:
@@ -3322,7 +3327,14 @@ asynchronous workers. Instances are created/deleted with
33223327

33233328
The `execute` and `complete` callbacks are functions that will be
33243329
invoked when the executor is ready to execute and when it completes its
3325-
task respectively. These functions implement the following interfaces:
3330+
task respectively.
3331+
3332+
The `execute` function should avoid making any N-API calls
3333+
that could result in the execution of JavaScript or interaction with
3334+
JavaScript objects. Most often, any code that needs to make N-API
3335+
calls should be made in `complete` callback instead.
3336+
3337+
These functions implement the following interfaces:
33263338

33273339
```C
33283340
typedef void (*napi_async_execute_callback)(napi_env env,

0 commit comments

Comments
 (0)