Skip to content

Commit c718592

Browse files
joyeecheungBridgeAR
authored andcommitted
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 <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent cb73fed commit c718592

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

lib/internal/bootstrap/node.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,11 @@ function startup() {
151151
}
152152

153153
if (config.hasInspector) {
154-
NativeModule.require('internal/inspector_async_hook').setup();
154+
const {
155+
enable,
156+
disable
157+
} = NativeModule.require('internal/inspector_async_hook');
158+
internalBinding('inspector').registerAsyncHook(enable, disable);
155159
}
156160

157161
// If the process is spawned with env NODE_CHANNEL_FD, it's probably

lib/internal/inspector_async_hook.js

+4-9
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
'use strict';
22

3-
const inspector = internalBinding('inspector');
4-
5-
if (!inspector || !inspector.asyncTaskScheduled) {
6-
exports.setup = function() {};
7-
return;
8-
}
9-
103
let hook;
114
let config;
125

136
function lazyHookCreation() {
7+
const inspector = internalBinding('inspector');
148
const { createHook } = require('async_hooks');
159
config = internalBinding('config');
1610

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

75-
exports.setup = function() {
76-
inspector.registerAsyncHook(enable, disable);
69+
module.exports = {
70+
enable,
71+
disable
7772
};

0 commit comments

Comments
 (0)