fix: do not call after() async_hook for asyncId 0 (#40593)

fix: do not call after() async_hook for asyncId 0

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
trop[bot]
2023-11-23 11:13:53 +01:00
committed by GitHub
parent 3383d3a6a8
commit 7bf0462385

View File

@@ -216,8 +216,11 @@ void ErrorMessageListener(v8::Local<v8::Message> message,
// Analogous to node/lib/internal/process/execution.js#L176-L180
if (env->async_hooks()->fields()[node::AsyncHooks::kAfter]) {
while (env->async_hooks()->fields()[node::AsyncHooks::kStackLength]) {
node::AsyncWrap::EmitAfter(env, env->execution_async_id());
env->async_hooks()->pop_async_context(env->execution_async_id());
double id = env->execution_async_id();
// Do not call EmitAfter for asyncId 0.
if (id != 0)
node::AsyncWrap::EmitAfter(env, id);
env->async_hooks()->pop_async_context(id);
}
}