diff --git a/src/api/callback.cc b/src/api/callback.cc index fb0e5586eb400a..fad78956f27d43 100644 --- a/src/api/callback.cc +++ b/src/api/callback.cc @@ -56,6 +56,12 @@ InternalCallbackScope::InternalCallbackScope(Environment* env, CHECK_NOT_NULL(env); env->PushAsyncCallbackScope(); + // Skip costly pushing/popping if we pass zeroes as async context + if (async_context_.async_id == 0) { + pushed_ids_ = false; + return; + } + if (!env->can_call_into_js()) { failed_ = true; return;