diff options
author | Anna Henningsen <anna@addaleax.net> | 2018-10-20 11:51:29 +0200 |
---|---|---|
committer | Matheus Marchini <mat@mmarchini.me> | 2018-10-24 11:20:35 -0300 |
commit | 5d80ae3acdd812651b3b193cd31e0b81c214b50e (patch) | |
tree | efb0548ce0f26174dee13feeadab072c2c9461e5 /lib/trace_events.js | |
parent | 036fbdb63d603a64bd8562ec9331dfb7a5c5075c (diff) | |
download | node-new-5d80ae3acdd812651b3b193cd31e0b81c214b50e.tar.gz |
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 <refack@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Matheus Marchini <mat@mmarchini.me>
Diffstat (limited to 'lib/trace_events.js')
-rw-r--r-- | lib/trace_events.js | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/trace_events.js b/lib/trace_events.js index bf303c28b7..878580c67f 100644 --- a/lib/trace_events.js +++ b/lib/trace_events.js @@ -13,7 +13,8 @@ const { ERR_INVALID_ARG_TYPE } = require('internal/errors').codes; -if (!hasTracing) +const { isMainThread } = require('internal/worker'); +if (!hasTracing || !isMainThread) throw new ERR_TRACE_EVENTS_UNAVAILABLE(); const { CategorySet, getEnabledCategories } = internalBinding('trace_events'); |