1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 15:04:11 -05:00

fix(napi): don't panic if symbol can't be found (#19397)

This should return an error to the caller to make it
easier to track what went wrong. 

Should help with debugging https://github.com/denoland/deno/issues/19389
This commit is contained in:
Bartek Iwańczuk 2023-06-08 01:26:41 +02:00 committed by GitHub
parent 21084a127f
commit 90c2bcdcf8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -647,12 +647,13 @@ where
// SAFETY: we are going blind, calling the register function on the other side.
let maybe_exports = unsafe {
let init = library
let Ok(init) = library
.get::<unsafe extern "C" fn(
env: napi_env,
exports: napi_value,
) -> napi_value>(b"napi_register_module_v1")
.expect("napi_register_module_v1 not found");
) -> napi_value>(b"napi_register_module_v1") else {
return Err(type_error(format!("Unable to find napi_register_module_v1 symbol in {}", path)));
};
init(
env_ptr,
std::mem::transmute::<v8::Local<v8::Value>, napi_value>(exports.into()),