Skip to content

Commit a6b337d

Browse files
committed
fixup! src: use symbol to store AsyncWrap resource
1 parent dd44bb9 commit a6b337d

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/async_wrap.cc

+4-4
Original file line numberDiff line numberDiff line change
@@ -534,12 +534,12 @@ void AsyncWrap::GetProviderType(const FunctionCallbackInfo<Value>& args) {
534534
}
535535

536536

537-
void AsyncWrap::EmitDestroy() {
537+
void AsyncWrap::EmitDestroy(bool from_gc) {
538538
AsyncWrap::EmitDestroy(env(), async_id_);
539539
// Ensure no double destroy is emitted via AsyncReset().
540540
async_id_ = kInvalidAsyncId;
541541

542-
if (!persistent().IsEmpty()) {
542+
if (!persistent().IsEmpty() && !from_gc) {
543543
HandleScope handle_scope(env()->isolate());
544544
USE(object()->Set(env()->context(), env()->resource_symbol(), object()));
545545
}
@@ -727,7 +727,7 @@ bool AsyncWrap::IsDoneInitializing() const {
727727

728728
AsyncWrap::~AsyncWrap() {
729729
EmitTraceEventDestroy();
730-
EmitDestroy();
730+
EmitDestroy(true /* from gc */);
731731
}
732732

733733
void AsyncWrap::EmitTraceEventDestroy() {
@@ -853,7 +853,7 @@ MaybeLocal<Value> AsyncWrap::MakeCallback(const Local<Function> cb,
853853
ProviderType provider = provider_type();
854854
async_context context { get_async_id(), get_trigger_async_id() };
855855
MaybeLocal<Value> ret = InternalMakeCallback(
856-
env(), GetResource(), object(), cb, argc, argv, context);
856+
env(), object(), object(), cb, argc, argv, context);
857857

858858
// This is a static call with cached values because the `this` object may
859859
// no longer be alive at this point.

src/async_wrap.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ class AsyncWrap : public BaseObject {
152152
static void EmitAfter(Environment* env, double async_id);
153153
static void EmitPromiseResolve(Environment* env, double async_id);
154154

155-
void EmitDestroy();
155+
void EmitDestroy(bool from_gc = false);
156156

157157
void EmitTraceEventBefore();
158158
static void EmitTraceEventAfter(ProviderType type, double async_id);

0 commit comments

Comments
 (0)