Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
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
};