File tree 1 file changed +7
-0
lines changed
1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -350,6 +350,10 @@ class DestroyParam {
350
350
Global<Object> propBag;
351
351
};
352
352
353
+ static void DestroyParamCleanupHook (void * ptr) {
354
+ delete static_cast <DestroyParam*>(ptr);
355
+ }
356
+
353
357
void AsyncWrap::WeakCallback (const WeakCallbackInfo<DestroyParam>& info) {
354
358
HandleScope scope (info.GetIsolate ());
355
359
@@ -358,6 +362,8 @@ void AsyncWrap::WeakCallback(const WeakCallbackInfo<DestroyParam>& info) {
358
362
p->propBag );
359
363
Local<Value> val;
360
364
365
+ p->env ->RemoveCleanupHook (DestroyParamCleanupHook, p.get ());
366
+
361
367
if (!prop_bag->Get (p->env ->context (), p->env ->destroyed_string ())
362
368
.ToLocal (&val)) {
363
369
return ;
@@ -382,6 +388,7 @@ static void RegisterDestroyHook(const FunctionCallbackInfo<Value>& args) {
382
388
p->target .Reset (isolate, args[0 ].As <Object>());
383
389
p->propBag .Reset (isolate, args[2 ].As <Object>());
384
390
p->target .SetWeak (p, AsyncWrap::WeakCallback, WeakCallbackType::kParameter );
391
+ p->env ->AddCleanupHook (DestroyParamCleanupHook, p);
385
392
}
386
393
387
394
void AsyncWrap::GetAsyncId (const FunctionCallbackInfo<Value>& args) {
You can’t perform that action at this time.
0 commit comments