mirror of
https://github.com/denoland/deno.git
synced 2025-08-04 02:48:24 +00:00
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>
This commit is contained in:
parent
7ae55e75d8
commit
512d5337c4
9 changed files with 186 additions and 91 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue