1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-24 08:09:08 -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
parent 5d844f76e7
commit 6890f58a03
No known key found for this signature in database
GPG key ID: 0C6BCDDC3B3AD750

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()),