diff --git a/src/stream_base-inl.h b/src/stream_base-inl.h index ef7a5e4c7a87f2..dd80683af10d08 100644 --- a/src/stream_base-inl.h +++ b/src/stream_base-inl.h @@ -4,6 +4,7 @@ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS #include "async_wrap-inl.h" +#include "base_object-inl.h" #include "node.h" #include "stream_base.h" #include "v8.h" @@ -36,9 +37,10 @@ inline StreamReq* StreamReq::FromObject(v8::Local req_wrap_obj) { } inline void StreamReq::Dispose() { + BaseObjectPtr destroy_me{GetAsyncWrap()}; object()->SetAlignedPointerInInternalField( StreamReq::kStreamReqField, nullptr); - delete this; + destroy_me->Detach(); } inline v8::Local StreamReq::object() {