@@ -462,7 +462,7 @@ typedef enum {
462462 napi_date_expected,
463463 napi_arraybuffer_expected,
464464 napi_detachable_arraybuffer_expected,
465- napi_would_deadlock,
465+ napi_would_deadlock, /* unused */
466466} napi_status;
467467```
468468
@@ -5124,18 +5124,9 @@ preventing data from being successfully added to the queue. If set to
51245124`napi_call_threadsafe_function()` never blocks if the thread-safe function was
51255125created with a maximum queue size of 0.
51265126
5127- As a special case, when `napi_call_threadsafe_function()` is called from a
5128- JavaScript thread, it will return `napi_would_deadlock` if the queue is full
5129- and it was called with `napi_tsfn_blocking`. The reason for this is that the
5130- JavaScript thread is responsible for removing items from the queue, thereby
5131- reducing their number. Thus, if it waits for room to become available on the
5132- queue, then it will deadlock.
5133-
5134- `napi_call_threadsafe_function()` will also return `napi_would_deadlock` if the
5135- thread-safe function created on one JavaScript thread is called from another
5136- JavaScript thread. The reason for this is to prevent a deadlock arising from the
5137- possibility that the two JavaScript threads end up waiting on one another,
5138- thereby both deadlocking.
5127+ `napi_call_threadsafe_function()` should not be called with `napi_tsfn_blocking`
5128+ from a JavaScript thread, because, if the queue is full, it may cause the
5129+ JavaScript thread to deadlock.
51395130
51405131The actual call into JavaScript is controlled by the callback given via the
51415132`call_js_cb` parameter. `call_js_cb` is invoked on the main thread once for each
@@ -5276,6 +5267,10 @@ This API may be called from any thread which makes use of `func`.
52765267added: v10.6.0
52775268napiVersion: 4
52785269changes:
5270+ - version: REPLACEME
5271+ pr-url: https://github.com/nodejs/node/pull/33453
5272+ description: >
5273+ Support for `napi_would_deadlock` has been reverted.
52795274 - version: v14.1.0
52805275 pr-url: https://github.com/nodejs/node/pull/32689
52815276 description: >
@@ -5298,13 +5293,13 @@ napi_call_threadsafe_function(napi_threadsafe_function func,
52985293 `napi_tsfn_nonblocking` to indicate that the call should return immediately
52995294 with a status of `napi_queue_full` whenever the queue is full.
53005295
5301- This API will return `napi_would_deadlock` if called with `napi_tsfn_blocking`
5302- from the main thread and the queue is full.
5296+ This API should not be called with `napi_tsfn_blocking` from a JavaScript
5297+ thread, because, if the queue is full, it may cause the JavaScript thread to
5298+ deadlock.
53035299
53045300This API will return `napi_closing` if `napi_release_threadsafe_function()` was
5305- called with `abort` set to `napi_tsfn_abort` from any thread.
5306-
5307- The value is only added to the queue if the API returns `napi_ok`.
5301+ called with `abort` set to `napi_tsfn_abort` from any thread. The value is only
5302+ added to the queue if the API returns `napi_ok`.
53085303
53095304This API may be called from any thread which makes use of `func`.
53105305
0 commit comments