We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
napi_remove_wrap()
ObjectWrap
1 parent f4bfde2 commit 0fd142bCopy full SHA for 0fd142b
napi-inl.h
@@ -2815,8 +2815,12 @@ inline ObjectWrap<T>::ObjectWrap(const Napi::CallbackInfo& callbackInfo) {
2815
2816
template <typename T>
2817
inline ObjectWrap<T>::~ObjectWrap() {
2818
+ // If the JS object still exists at this point, remove the finalizer added
2819
+ // through `napi_wrap()`.
2820
if (!IsEmpty()) {
2821
Object object = Value();
2822
+ // It is not valid to call `napi_remove_wrap()` with an empty `object`.
2823
+ // This happens e.g. during garbage collection.
2824
if (!object.IsEmpty())
2825
napi_remove_wrap(Env(), object, nullptr);
2826
}
0 commit comments