Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/internal/bootstrap/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,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
Expand Down
13 changes: 4 additions & 9 deletions lib/internal/inspector_async_hook.js
Original file line number Diff line number Diff line change
@@ -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');

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

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