Skip to content
Permalink
Browse files

process: register the inspector async hooks in bootstrap/node.js

So it's easier to tell the side effects of this setup.

PR-URL: #25443
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information...
joyeecheung authored and BridgeAR committed Jan 10, 2019
1 parent cb73fed commit c718592147cd3a60b5cc74f186ae14ed1b73a01f
Showing with 9 additions and 10 deletions.
  1. +5 −1 lib/internal/bootstrap/node.js
  2. +4 −9 lib/internal/inspector_async_hook.js
@@ -151,7 +151,11 @@ function startup() {
}

if (config.hasInspector) {
NativeModule.require('internal/inspector_async_hook').setup();
const {
enable,
disable
} = NativeModule.require('internal/inspector_async_hook');
internalBinding('inspector').registerAsyncHook(enable, disable);
}

// If the process is spawned with env NODE_CHANNEL_FD, it's probably
@@ -1,16 +1,10 @@
'use strict';

const inspector = internalBinding('inspector');

if (!inspector || !inspector.asyncTaskScheduled) {
exports.setup = function() {};
return;
}

let hook;
let config;

function lazyHookCreation() {
const inspector = internalBinding('inspector');
const { createHook } = require('async_hooks');
config = internalBinding('config');

@@ -72,6 +66,7 @@ function disable() {
hook.disable();
}

exports.setup = function() {
inspector.registerAsyncHook(enable, disable);
module.exports = {
enable,
disable
};

0 comments on commit c718592

Please sign in to comment.
You can’t perform that action at this time.