From 512d5337c480a2a2704881d3fe1c40b6e0445cf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Fri, 26 May 2023 06:40:17 +0200 Subject: 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 --- test_napi/common.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'test_napi/common.js') diff --git a/test_napi/common.js b/test_napi/common.js index 09378918f..ce9b2544b 100644 --- a/test_napi/common.js +++ b/test_napi/common.js @@ -9,17 +9,19 @@ export { export { fromFileUrl } from "../test_util/std/path/mod.ts"; const targetDir = Deno.execPath().replace(/[^\/\\]+$/, ""); -const [libPrefix, libSuffix] = { +export const [libPrefix, libSuffix] = { darwin: ["lib", "dylib"], linux: ["lib", "so"], windows: ["", "dll"], }[Deno.build.os]; +const ops = Deno[Deno.internal].core.ops; + export function loadTestLibrary() { const specifier = `${targetDir}/${libPrefix}test_napi.${libSuffix}`; // Internal, used in ext/node - return Deno[Deno.internal].core.ops.op_napi_open(specifier, { + return ops.op_napi_open(specifier, { Buffer: {}, }); } -- cgit v1.2.3