diff --git a/crates/napi/src/error.rs b/crates/napi/src/error.rs index 9fb12f0c..90f96e03 100644 --- a/crates/napi/src/error.rs +++ b/crates/napi/src/error.rs @@ -162,13 +162,16 @@ impl From for Error { impl Drop for Error { fn drop(&mut self) { - if !self.maybe_env.is_null() && !self.maybe_raw.is_null() { - let delete_reference_status = - unsafe { sys::napi_delete_reference(self.maybe_env, self.maybe_raw) }; - debug_assert!( - delete_reference_status == sys::Status::napi_ok, - "Delete Error Reference failed" - ); + #[cfg(not(feature = "noop"))] + { + if !self.maybe_env.is_null() && !self.maybe_raw.is_null() { + let delete_reference_status = + unsafe { sys::napi_delete_reference(self.maybe_env, self.maybe_raw) }; + debug_assert!( + delete_reference_status == sys::Status::napi_ok, + "Delete Error Reference failed" + ); + } } } }