@@ -34,11 +34,12 @@ CallbackScope::~CallbackScope() {
3434 delete private_;
3535}
3636
37- InternalCallbackScope::InternalCallbackScope (AsyncWrap* async_wrap)
37+ InternalCallbackScope::InternalCallbackScope (AsyncWrap* async_wrap, int flags )
3838 : InternalCallbackScope(async_wrap->env (),
3939 async_wrap->object(),
4040 { async_wrap->get_async_id (),
41- async_wrap->get_trigger_async_id () }) {}
41+ async_wrap->get_trigger_async_id () },
42+ flags) {}
4243
4344InternalCallbackScope::InternalCallbackScope (Environment* env,
4445 Local<Object> object,
@@ -47,10 +48,11 @@ InternalCallbackScope::InternalCallbackScope(Environment* env,
4748 : env_(env),
4849 async_context_ (asyncContext),
4950 object_(object),
50- callback_scope_(env ),
51- skip_hooks_ (flags & kSkipAsyncHooks ) {
51+ skip_hooks_(flags & kSkipAsyncHooks ),
52+ skip_task_queues_ (flags & kSkipTaskQueues ) {
5253 CHECK_IMPLIES (!(flags & kAllowEmptyResource ), !object.IsEmpty ());
5354 CHECK_NOT_NULL (env);
55+ env->PushAsyncCallbackScope ();
5456
5557 if (!env->can_call_into_js ()) {
5658 failed_ = true ;
@@ -74,6 +76,7 @@ InternalCallbackScope::InternalCallbackScope(Environment* env,
7476
7577InternalCallbackScope::~InternalCallbackScope () {
7678 Close ();
79+ env_->PopAsyncCallbackScope ();
7780}
7881
7982void InternalCallbackScope::Close () {
@@ -94,7 +97,7 @@ void InternalCallbackScope::Close() {
9497 AsyncWrap::EmitAfter (env_, async_context_.async_id );
9598 }
9699
97- if (env_->async_callback_scope_depth () > 1 ) {
100+ if (env_->async_callback_scope_depth () > 1 || skip_task_queues_ ) {
98101 return ;
99102 }
100103
0 commit comments