From adaa3f4d7dcdc909b650c429bc05367f476b0213 Mon Sep 17 00:00:00 2001 From: Robert Nagy Date: Wed, 22 Dec 2021 09:25:33 +0100 Subject: [PATCH] src: skip costly pushing/popping if we pass zeroes as async context --- src/api/callback.cc | 6 ++++++ 1 file changed, 6 insertions(+) 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;