@@ -534,12 +534,12 @@ void AsyncWrap::GetProviderType(const FunctionCallbackInfo<Value>& args) {
534
534
}
535
535
536
536
537
- void AsyncWrap::EmitDestroy () {
537
+ void AsyncWrap::EmitDestroy (bool from_gc ) {
538
538
AsyncWrap::EmitDestroy (env (), async_id_);
539
539
// Ensure no double destroy is emitted via AsyncReset().
540
540
async_id_ = kInvalidAsyncId ;
541
541
542
- if (!persistent ().IsEmpty ()) {
542
+ if (!persistent ().IsEmpty () && !from_gc ) {
543
543
HandleScope handle_scope (env ()->isolate ());
544
544
USE (object ()->Set (env ()->context (), env ()->resource_symbol (), object ()));
545
545
}
@@ -727,7 +727,7 @@ bool AsyncWrap::IsDoneInitializing() const {
727
727
728
728
AsyncWrap::~AsyncWrap () {
729
729
EmitTraceEventDestroy ();
730
- EmitDestroy ();
730
+ EmitDestroy (true /* from gc */ );
731
731
}
732
732
733
733
void AsyncWrap::EmitTraceEventDestroy () {
@@ -853,7 +853,7 @@ MaybeLocal<Value> AsyncWrap::MakeCallback(const Local<Function> cb,
853
853
ProviderType provider = provider_type ();
854
854
async_context context { get_async_id (), get_trigger_async_id () };
855
855
MaybeLocal<Value> ret = InternalMakeCallback (
856
- env (), GetResource (), object (), cb, argc, argv, context);
856
+ env (), object (), object (), cb, argc, argv, context);
857
857
858
858
// This is a static call with cached values because the `this` object may
859
859
// no longer be alive at this point.
0 commit comments