From e2ced0d40153af12063e1ce4fa33327e03a408f1 Mon Sep 17 00:00:00 2001 From: Nicolai Stange Date: Sun, 29 Nov 2020 03:11:30 +0100 Subject: [PATCH] perf_hooks: invoke performance_entry_callback via MakeSyncCallback() It's desirable to retain async_contexts active at callsites of perf_hooks.performance.mark() and alike in the subsequent PerformanceObserver invocations such that the latter can access e.g. associated AsyncLocalStorage instances. In working towards this goal replace the node::MakeCallback(..., async_context{0, 0}) in PerformanceEntry::doNotify() by the new node::MakeSyncCallback() introduced specifically for this purpose. This change will retain the original async_context, if any, in perf_hook's observersCallback() and thus, for the subsequent doNotify() on unbuffered PerformanceObservers. Co-Authored-By: ZauberNerd PR-URL: https://github.com/nodejs/node/pull/36343 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Rich Trott --- src/node_perf.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/node_perf.cc b/src/node_perf.cc index 5fa4eabc9934de..1eddb00f48a6d2 100644 --- a/src/node_perf.cc +++ b/src/node_perf.cc @@ -159,11 +159,10 @@ void PerformanceEntry::Notify(Environment* env, AliasedUint32Array& observers = env->performance_state()->observers; if (!env->performance_entry_callback().IsEmpty() && type != NODE_PERFORMANCE_ENTRY_TYPE_INVALID && observers[type]) { - node::MakeCallback(env->isolate(), - object.As(), - env->performance_entry_callback(), - 1, &object, - node::async_context{0, 0}); + node::MakeSyncCallback(env->isolate(), + object.As(), + env->performance_entry_callback(), + 1, &object); } }