From 5d80ae3acdd812651b3b193cd31e0b81c214b50e Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Sat, 20 Oct 2018 11:51:29 +0200 Subject: [PATCH] trace_events: forbid tracing modifications from worker threads Forbid modifying tracing state from worker threads, either through the built-in module or inspector sessions, since the main thread owns all global state, and at least the `async_hooks` integration is definitely not thread safe in its current state. PR-URL: https://github.com/nodejs/node/pull/23781 Fixes: https://github.com/nodejs/node/issues/22767 Refs: https://github.com/nodejs/node/issues/22513 Reviewed-By: Refael Ackermann Reviewed-By: Richard Lau Reviewed-By: Matheus Marchini --- doc/api/tracing.md | 3 ++ doc/api/worker_threads.md | 2 ++ lib/trace_events.js | 3 +- src/env.cc | 13 ++++++++- src/inspector/tracing_agent.cc | 4 +++ .../test-trace-events-api-worker-disabled.js | 11 ++++++++ ...-events-dynamic-enable-workers-disabled.js | 28 +++++++++++++++++++ 7 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 test/parallel/test-trace-events-api-worker-disabled.js create mode 100644 test/parallel/test-trace-events-dynamic-enable-workers-disabled.js diff --git a/doc/api/tracing.md b/doc/api/tracing.md index 04db3f12f42e2e..10b2f61ea5a5b9 100644 --- a/doc/api/tracing.md +++ b/doc/api/tracing.md @@ -82,6 +82,8 @@ as the one used by `process.hrtime()` however the trace-event timestamps are expressed in microseconds, unlike `process.hrtime()` which returns nanoseconds. +The features from this module are not available in [`Worker`][] threads. + ## The `trace_events` module