summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2023-06-08 01:26:41 +0200
committerGitHub <noreply@github.com>2023-06-07 23:26:41 +0000
commit90c2bcdcf81f37d2e40ef2c8abf46fe912cac1d0 (patch)
tree1c2b17e817b1857834921aac87aa27be48a1cbcf /ext
parent21084a127f794e899a5e16a81cc832b665298aff (diff)
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
Diffstat (limited to 'ext')
-rw-r--r--ext/napi/lib.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/ext/napi/lib.rs b/ext/napi/lib.rs
index 22d86e4a9..ada9aa13f 100644
--- a/ext/napi/lib.rs
+++ b/ext/napi/lib.rs
@@ -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()),