File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed
Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -348,6 +348,10 @@ class DestroyParam {
348348 Global<Object> propBag;
349349};
350350
351+ static void DestroyParamCleanupHook (void * ptr) {
352+ delete static_cast <DestroyParam*>(ptr);
353+ }
354+
351355void AsyncWrap::WeakCallback (const WeakCallbackInfo<DestroyParam>& info) {
352356 HandleScope scope (info.GetIsolate ());
353357
@@ -356,6 +360,8 @@ void AsyncWrap::WeakCallback(const WeakCallbackInfo<DestroyParam>& info) {
356360 p->propBag );
357361 Local<Value> val;
358362
363+ p->env ->RemoveCleanupHook (DestroyParamCleanupHook, p.get ());
364+
359365 if (!prop_bag->Get (p->env ->context (), p->env ->destroyed_string ())
360366 .ToLocal (&val)) {
361367 return ;
@@ -380,6 +386,7 @@ static void RegisterDestroyHook(const FunctionCallbackInfo<Value>& args) {
380386 p->target .Reset (isolate, args[0 ].As <Object>());
381387 p->propBag .Reset (isolate, args[2 ].As <Object>());
382388 p->target .SetWeak (p, AsyncWrap::WeakCallback, WeakCallbackType::kParameter );
389+ p->env ->AddCleanupHook (DestroyParamCleanupHook, p);
383390}
384391
385392
You can’t perform that action at this time.
0 commit comments