@@ -398,6 +398,7 @@ static void DisablePromiseHook(const FunctionCallbackInfo<Value>& args) {
398
398
class DestroyParam {
399
399
public:
400
400
double asyncId;
401
+ Environment* env;
401
402
Persistent<Object> target;
402
403
Persistent<Object> propBag;
403
404
};
@@ -406,13 +407,12 @@ class DestroyParam {
406
407
void AsyncWrap::WeakCallback (const v8::WeakCallbackInfo<DestroyParam>& info) {
407
408
HandleScope scope (info.GetIsolate ());
408
409
409
- Environment* env = Environment::GetCurrent (info.GetIsolate ());
410
410
std::unique_ptr<DestroyParam> p{info.GetParameter ()};
411
411
Local<Object> prop_bag = PersistentToLocal (info.GetIsolate (), p->propBag );
412
412
413
- Local<Value> val = prop_bag->Get (env->destroyed_string ());
413
+ Local<Value> val = prop_bag->Get (p-> env ->destroyed_string ());
414
414
if (val->IsFalse ()) {
415
- AsyncWrap::EmitDestroy (env, p->asyncId );
415
+ AsyncWrap::EmitDestroy (p-> env , p->asyncId );
416
416
}
417
417
// unique_ptr goes out of scope here and pointer is deleted.
418
418
}
@@ -426,6 +426,7 @@ static void RegisterDestroyHook(const FunctionCallbackInfo<Value>& args) {
426
426
Isolate* isolate = args.GetIsolate ();
427
427
DestroyParam* p = new DestroyParam ();
428
428
p->asyncId = args[1 ].As <Number>()->Value ();
429
+ p->env = Environment::GetCurrent (args);
429
430
p->target .Reset (isolate, args[0 ].As <Object>());
430
431
p->propBag .Reset (isolate, args[2 ].As <Object>());
431
432
p->target .SetWeak (
0 commit comments