summaryrefslogtreecommitdiff
path: root/lib/internal/bootstrap/pre_execution.js
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2019-03-12 18:34:22 +0800
committerJoyee Cheung <joyeec9h3@gmail.com>2019-03-19 05:37:20 +0800
commita91d36fcc12c90f842d38f4a6b50809133bf1bc7 (patch)
tree0ff1ec46eeadb162af18d4d7390dd3c77e55dff8 /lib/internal/bootstrap/pre_execution.js
parente2a2f9398e30faaadf1e124844112b89322fae2e (diff)
downloadandroid-node-v8-a91d36fcc12c90f842d38f4a6b50809133bf1bc7.tar.gz
android-node-v8-a91d36fcc12c90f842d38f4a6b50809133bf1bc7.tar.bz2
android-node-v8-a91d36fcc12c90f842d38f4a6b50809133bf1bc7.zip
process: set the trace category update handler during bootstrap
Set the trace category update handler during bootstrap, but delay the initial invocation of it until pre-execution. In addition, do not serialize the `node.async_hooks` category state when loading the trace_event binding during bootstrap, since it depends on run time states (e.g. CLI flags). Instead, use the `isTraceCategoryEnabled` v8 intrinsics to query that value during pre-execution. PR-URL: https://github.com/nodejs/node/pull/26605 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'lib/internal/bootstrap/pre_execution.js')
-rw-r--r--lib/internal/bootstrap/pre_execution.js26
1 files changed, 3 insertions, 23 deletions
diff --git a/lib/internal/bootstrap/pre_execution.js b/lib/internal/bootstrap/pre_execution.js
index 04083b53a2..c38822bd89 100644
--- a/lib/internal/bootstrap/pre_execution.js
+++ b/lib/internal/bootstrap/pre_execution.js
@@ -1,9 +1,6 @@
'use strict';
const { getOptionValue } = require('internal/options');
-// Lazy load internal/trace_events_async_hooks only if the async_hooks
-// trace event category is enabled.
-let traceEventsAsyncHook;
function prepareMainThreadExecution() {
// Patch the process object with legacy properties and normalizations
@@ -162,26 +159,9 @@ function initializeReportSignalHandlers() {
}
function setupTraceCategoryState() {
- const {
- asyncHooksEnabledInitial,
- setTraceCategoryStateUpdateHandler
- } = internalBinding('trace_events');
-
- toggleTraceCategoryState(asyncHooksEnabledInitial);
- setTraceCategoryStateUpdateHandler(toggleTraceCategoryState);
-}
-
-// Dynamically enable/disable the traceEventsAsyncHook
-function toggleTraceCategoryState(asyncHooksEnabled) {
- if (asyncHooksEnabled) {
- if (!traceEventsAsyncHook) {
- traceEventsAsyncHook =
- require('internal/trace_events_async_hooks').createHook();
- }
- traceEventsAsyncHook.enable();
- } else if (traceEventsAsyncHook) {
- traceEventsAsyncHook.disable();
- }
+ const { isTraceCategoryEnabled } = internalBinding('trace_events');
+ const { toggleTraceCategoryState } = require('internal/process/per_thread');
+ toggleTraceCategoryState(isTraceCategoryEnabled('node.async_hooks'));
}
// In general deprecations are intialized wherever the APIs are implemented,