File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -134,6 +134,22 @@ const isWindows = process.platform === 'win32';
134134const noop = ( ) => { } ;
135135
136136const kPerfHooksNetConnectContext = Symbol ( 'kPerfHooksNetConnectContext' ) ;
137+
138+ let netClientSocketChannel ;
139+ let netServerSocketChannel ;
140+ function lazyChannels ( ) {
141+ // TODO(joyeecheung): support diagnostics channels in the snapshot.
142+ // For now it is fine to create them lazily when there isn't a snapshot to
143+ // build. If users need the channels they would have to create them first
144+ // before invoking any built-ins that would publish to these channels
145+ // anyway.
146+ if ( netClientSocketChannel === undefined ) {
147+ const dc = require ( 'diagnostics_channel' ) ;
148+ netClientSocketChannel = dc . channel ( 'net.client.socket' ) ;
149+ netServerSocketChannel = dc . channel ( 'net.server.socket' ) ;
150+ }
151+ }
152+
137153const {
138154 hasObserver,
139155 startPerf,
@@ -205,7 +221,7 @@ function connect(...args) {
205221 const options = normalized [ 0 ] ;
206222 debug ( 'createConnection' , normalized ) ;
207223 const socket = new Socket ( options ) ;
208-
224+ lazyChannels ( ) ;
209225 if ( options . timeout ) {
210226 socket . setTimeout ( options . timeout ) ;
211227 }
@@ -1737,6 +1753,7 @@ function onconnection(err, clientHandle) {
17371753
17381754 DTRACE_NET_SERVER_CONNECTION ( socket ) ;
17391755 self . emit ( 'connection' , socket ) ;
1756+ lazyChannels ( ) ;
17401757}
17411758
17421759/**
You can’t perform that action at this time.
0 commit comments