diff --git a/src/node_jsvmapi.cc b/src/node_jsvmapi.cc index 2f9dba07e8..11e09b674c 100644 --- a/src/node_jsvmapi.cc +++ b/src/node_jsvmapi.cc @@ -147,7 +147,12 @@ namespace v8impl { _finalizeCallback(finalizeCallback), _finalizeData(finalizeData) { if (initialRefcount == 0) { - _persistent.SetWeak(this, FinalizeCallback, v8::WeakCallbackType::kParameter); + if (_finalizeCallback != nullptr || _deleteSelf) { + _persistent.SetWeak(this, FinalizeCallback, v8::WeakCallbackType::kParameter); + } + else { + _persistent.SetWeak(); + } _persistent.MarkIndependent(); } } @@ -172,7 +177,12 @@ namespace v8impl { int Release() { if (--_refcount == 0) { - _persistent.SetWeak(this, FinalizeCallback, v8::WeakCallbackType::kParameter); + if (_finalizeCallback != nullptr || _deleteSelf) { + _persistent.SetWeak(this, FinalizeCallback, v8::WeakCallbackType::kParameter); + } + else { + _persistent.SetWeak(); + } _persistent.MarkIndependent(); } @@ -721,7 +731,7 @@ napi_status napi_define_class( } napi_status status = napi_define_properties( - e, *result, staticDescriptors.size(), staticDescriptors.data()); + e, *result, static_cast(staticDescriptors.size()), staticDescriptors.data()); if (status != napi_ok) return status; }