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 <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent cb73fed commit c718592

2 files changed

Lines changed: 9 additions & 10 deletions

File tree

‎lib/internal/bootstrap/node.js‎

Lines changed: 5 additions & 1 deletion
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‎

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
'use strict';
22

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

136
functionlazyHookCreation(){
7+
constinspector=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)