@@ -34,11 +34,12 @@ CallbackScope::~CallbackScope() {
34
34
delete private_;
35
35
}
36
36
37
- InternalCallbackScope::InternalCallbackScope (AsyncWrap* async_wrap)
37
+ InternalCallbackScope::InternalCallbackScope (AsyncWrap* async_wrap, int flags )
38
38
: InternalCallbackScope(async_wrap->env (),
39
39
async_wrap->object(),
40
40
{ async_wrap->get_async_id (),
41
- async_wrap->get_trigger_async_id () }) {}
41
+ async_wrap->get_trigger_async_id () },
42
+ flags) {}
42
43
43
44
InternalCallbackScope::InternalCallbackScope (Environment* env,
44
45
Local<Object> object,
@@ -47,10 +48,11 @@ InternalCallbackScope::InternalCallbackScope(Environment* env,
47
48
: env_(env),
48
49
async_context_ (asyncContext),
49
50
object_(object),
50
- callback_scope_(env ),
51
- skip_hooks_ (flags & kSkipAsyncHooks ) {
51
+ skip_hooks_(flags & kSkipAsyncHooks ),
52
+ skip_task_queues_ (flags & kSkipTaskQueues ) {
52
53
CHECK_IMPLIES (!(flags & kAllowEmptyResource ), !object.IsEmpty ());
53
54
CHECK_NOT_NULL (env);
55
+ env->PushAsyncCallbackScope ();
54
56
55
57
if (!env->can_call_into_js ()) {
56
58
failed_ = true ;
@@ -74,6 +76,7 @@ InternalCallbackScope::InternalCallbackScope(Environment* env,
74
76
75
77
InternalCallbackScope::~InternalCallbackScope () {
76
78
Close ();
79
+ env_->PopAsyncCallbackScope ();
77
80
}
78
81
79
82
void InternalCallbackScope::Close () {
@@ -94,7 +97,7 @@ void InternalCallbackScope::Close() {
94
97
AsyncWrap::EmitAfter (env_, async_context_.async_id );
95
98
}
96
99
97
- if (env_->async_callback_scope_depth () > 1 ) {
100
+ if (env_->async_callback_scope_depth () > 1 || skip_task_queues_ ) {
98
101
return ;
99
102
}
100
103
0 commit comments