diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2023-05-26 06:40:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-26 10:10:17 +0530 |
commit | 512d5337c480a2a2704881d3fe1c40b6e0445cf0 (patch) | |
tree | 99b03358883223a69f48b2d0e5b9387f3abae517 /cli | |
parent | 7ae55e75d812edc93251357465f8d49fc2fb5d26 (diff) |
fix(napi): clear currently registering module slot (#19249)
This commit fixes problem with loading N-API modules that use
the "old" way of registration (using "napi_module_register" API).
The slot was not cleared after loading modules, causing subsequent
calls that use the new way of registration (using
"napi_register_module_v1" API) to try and load the previous module.
Ref https://github.com/denoland/deno/issues/16460
---------
Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
Diffstat (limited to 'cli')
-rw-r--r-- | cli/napi/env.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/cli/napi/env.rs b/cli/napi/env.rs index 114c43026..decdd59d6 100644 --- a/cli/napi/env.rs +++ b/cli/napi/env.rs @@ -136,9 +136,10 @@ fn node_api_get_module_file_name( #[napi_sym::napi_sym] fn napi_module_register(module: *const NapiModule) -> napi_status { - MODULE.with(|cell| { + MODULE_TO_REGISTER.with(|cell| { let mut slot = cell.borrow_mut(); - slot.replace(module); + let prev = slot.replace(module); + assert!(prev.is_none()); }); napi_ok } |