From e56695daa89b7c53a88a691f35ee9a498caffbdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Wed, 24 May 2023 15:41:43 +0200 Subject: fix(napi): add napi_async_init and napi_async_destroy (#19234) We don't have support for "AsyncContext" in "node:async_hooks" module, so these two APIs are just noops. Towards https://github.com/denoland/deno/issues/18610. --- cli/napi/async.rs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'cli/napi/async.rs') diff --git a/cli/napi/async.rs b/cli/napi/async.rs index 80d128063..48de36728 100644 --- a/cli/napi/async.rs +++ b/cli/napi/async.rs @@ -2,6 +2,8 @@ use deno_runtime::deno_napi::*; +use crate::check_env; + #[repr(C)] pub struct AsyncWork { pub data: *mut c_void, @@ -69,19 +71,22 @@ fn napi_queue_async_work( napi_ok } -// TODO: Custom async operations. - +// NOTE: we don't support "async_hooks::AsyncContext" so these APIs are noops. #[napi_sym::napi_sym] fn napi_async_init( - _env: *mut Env, + env: *mut Env, _async_resource: napi_value, _async_resource_name: napi_value, - _result: *mut *mut (), + result: *mut *mut (), ) -> napi_status { - todo!() + check_env!(env); + *result = ptr::null_mut(); + napi_ok } #[napi_sym::napi_sym] -fn napi_async_destroy(_env: *mut Env, _async_context: *mut ()) -> napi_status { - todo!() +fn napi_async_destroy(env: *mut Env, async_context: *mut ()) -> napi_status { + check_env!(env); + assert!(async_context.is_null()); + napi_ok } -- cgit v1.2.3