Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node-api: make tsfn accept napi_finalize once more #51801

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/node_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1319,12 +1319,10 @@ napi_create_threadsafe_function(napi_env env,
size_t max_queue_size,
size_t initial_thread_count,
void* thread_finalize_data,
node_api_nogc_finalize nogc_thread_finalize_cb,
napi_finalize thread_finalize_cb,
void* context,
napi_threadsafe_function_call_js call_js_cb,
napi_threadsafe_function* result) {
napi_finalize thread_finalize_cb =
reinterpret_cast<napi_finalize>(nogc_thread_finalize_cb);
CHECK_ENV_NOT_IN_GC(env);
CHECK_ARG(env, async_resource_name);
RETURN_STATUS_IF_FALSE(env, initial_thread_count > 0, napi_invalid_arg);
Expand Down
2 changes: 1 addition & 1 deletion src/node_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ napi_create_threadsafe_function(napi_env env,
size_t max_queue_size,
size_t initial_thread_count,
void* thread_finalize_data,
node_api_nogc_finalize thread_finalize_cb,
napi_finalize thread_finalize_cb,
void* context,
napi_threadsafe_function_call_js call_js_cb,
napi_threadsafe_function* result);
Expand Down
14 changes: 1 addition & 13 deletions test/node-api/test_threadsafe_function/test_uncaught_exception.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,6 @@ static void ThreadSafeFunctionFinalize(napi_env env,
NODE_API_CALL_RETURN_VOID(env, napi_delete_reference(env, js_func_ref));
}

static void ThreadSafeFunctionNogcFinalize(node_api_nogc_env env,
void* data,
void* hint) {
#ifdef NAPI_EXPERIMENTAL
NODE_API_NOGC_CALL_RETURN_VOID(
env,
node_api_post_finalizer(env, ThreadSafeFunctionFinalize, data, hint));
#else
ThreadSafeFunctionFinalize(env, data, hint);
#endif
}

// Testing calling into JavaScript
static napi_value CallIntoModule(napi_env env, napi_callback_info info) {
size_t argc = 4;
Expand All @@ -46,7 +34,7 @@ static napi_value CallIntoModule(napi_env env, napi_callback_info info) {
0,
1,
finalize_func,
ThreadSafeFunctionNogcFinalize,
ThreadSafeFunctionFinalize,
NULL,
NULL,
&tsfn));
Expand Down