From 848df6f6cc88aac4802d169a1576effc562b57f1 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Sun, 29 Mar 2020 16:42:00 +0200 Subject: [PATCH] tracing: do not attempt to call into JS when disallowed PR-URL: https://github.com/nodejs/node/pull/32548 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- src/env.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/env.cc b/src/env.cc index c0b6af40693fca..c32cf2ff080a2c 100644 --- a/src/env.cc +++ b/src/env.cc @@ -207,7 +207,7 @@ void InitThreadLocalOnce() { } void TrackingTraceStateObserver::UpdateTraceCategoryState() { - if (!env_->owns_process_state()) { + if (!env_->owns_process_state() || !env_->can_call_into_js()) { // Ideally, we’d have a consistent story that treats all threads/Environment // instances equally here. However, tracing is essentially global, and this // callback is called from whichever thread calls `StartTracing()` or @@ -228,8 +228,7 @@ void TrackingTraceStateObserver::UpdateTraceCategoryState() { TryCatchScope try_catch(env_); try_catch.SetVerbose(true); Local args[] = {Boolean::New(isolate, async_hooks_enabled)}; - cb->Call(env_->context(), Undefined(isolate), arraysize(args), args) - .ToLocalChecked(); + USE(cb->Call(env_->context(), Undefined(isolate), arraysize(args), args)); } static std::atomic next_thread_id{0};