diff --git a/src/async_wrap.cc b/src/async_wrap.cc index 83882d9f805710..81b6ab12780f32 100644 --- a/src/async_wrap.cc +++ b/src/async_wrap.cc @@ -229,7 +229,7 @@ void AsyncWrap::EmitAfter(Environment* env, double async_id) { class PromiseWrap : public AsyncWrap { public: PromiseWrap(Environment* env, Local object, bool silent) - : AsyncWrap(env, object, silent) { + : AsyncWrap(env, object, PROVIDER_PROMISE, -1, silent) { MakeWeak(this); } size_t self_size() const override { return sizeof(*this); } @@ -586,32 +586,23 @@ AsyncWrap::AsyncWrap(Environment* env, Local object, ProviderType provider, double execution_async_id) - : BaseObject(env, object), - provider_type_(provider) { - CHECK_NE(provider, PROVIDER_NONE); - CHECK_GE(object->InternalFieldCount(), 1); + : AsyncWrap(env, object, provider, execution_async_id, false) {} - // Shift provider value over to prevent id collision. - persistent().SetWrapperClassId(NODE_ASYNC_ID_OFFSET + provider); - - // Use AsyncReset() call to execute the init() callbacks. - AsyncReset(execution_async_id); -} - - -// This is specifically used by the PromiseWrap constructor. AsyncWrap::AsyncWrap(Environment* env, Local object, + ProviderType provider, + double execution_async_id, bool silent) : BaseObject(env, object), - provider_type_(PROVIDER_PROMISE) { + provider_type_(provider) { + CHECK_NE(provider, PROVIDER_NONE); CHECK_GE(object->InternalFieldCount(), 1); // Shift provider value over to prevent id collision. persistent().SetWrapperClassId(NODE_ASYNC_ID_OFFSET + provider_type_); // Use AsyncReset() call to execute the init() callbacks. - AsyncReset(-1, silent); + AsyncReset(execution_async_id, silent); } diff --git a/src/async_wrap.h b/src/async_wrap.h index b7aed5d789754b..a9abfc8b75ca43 100644 --- a/src/async_wrap.h +++ b/src/async_wrap.h @@ -172,8 +172,11 @@ class AsyncWrap : public BaseObject { private: friend class PromiseWrap; - // This is specifically used by the PromiseWrap constructor. - AsyncWrap(Environment* env, v8::Local promise, bool silent); + AsyncWrap(Environment* env, + v8::Local promise, + ProviderType provider, + double execution_async_id, + bool silent); inline AsyncWrap(); const ProviderType provider_type_; // Because the values may be Reset(), cannot be made const.