node-api: make tsfn accept napi_finalize once more · nodejs/node@71616e8 · GitHub
Skip to content

Commit 71616e8

Browse files
gabrielschulhofrichardlau
authored andcommitted
node-api: make tsfn accept napi_finalize once more
The thread-safe function's finalizer is not called in conjunction with the garbage collection of a JS value. In fact, it keeps a strong reference to the JS function it is expected to call. Thus, it is safe to make calls that affect GC state from its body. PR-URL: #51801 Reviewed-By: Michael Dawson <midawson@redhat.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
1 parent 2c53ff3 commit 71616e8

3 files changed

Lines changed: 3 additions & 17 deletions

File tree

src/node_api.cc

Lines changed: 1 addition & 3 deletions

src/node_api.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ napi_create_threadsafe_function(napi_env env,
209209
size_t max_queue_size,
210210
size_t initial_thread_count,
211211
void* thread_finalize_data,
212-
node_api_nogc_finalize thread_finalize_cb,
212+
napi_finalize thread_finalize_cb,
213213
void* context,
214214
napi_threadsafe_function_call_js call_js_cb,
215215
napi_threadsafe_function* result);

test/node-api/test_threadsafe_function/test_uncaught_exception.c

Lines changed: 1 addition & 13 deletions

0 commit comments

Comments
 (0)