tracing: do not attempt to call into JS when disallowed

PR-URL: https://github.com/nodejs/node/pull/32548
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Anna Henningsen authored and Michaël Zasso committed 2020-04-11 10:01:15 +02:00
1 parent f0a31e33a8
commit 4e5271acfb
1 file changed
+2 -3
+2 -3
View File
@@ -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<Value> 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<uint64_t> next_thread_id{0};