@@ -131,18 +131,17 @@ const noop = () => {};
131131
132132const  kPerfHooksNetConnectContext  =  Symbol ( 'kPerfHooksNetConnectContext' ) ; 
133133
134- let  netClientSocketChannel ; 
135- let  netServerSocketChannel ; 
134+ const  CLIENT_SOCKET_CHANNEL  =  'net.client.socket' ; 
135+ const  SERVER_SOCKET_CHANNEL  =  'net.server.socket' ; 
136+ let  dc ; 
136137function  lazyChannels ( )  { 
137138  // TODO(joyeecheung): support diagnostics channels in the snapshot. 
138139  // For now it is fine to create them lazily when there isn't a snapshot to 
139140  // build. If users need the channels they would have to create them first 
140141  // before invoking any built-ins that would publish to these channels 
141142  // anyway. 
142-   if  ( netClientSocketChannel  ===  undefined )  { 
143-     const  dc  =  require ( 'diagnostics_channel' ) ; 
144-     netClientSocketChannel  =  dc . channel ( 'net.client.socket' ) ; 
145-     netServerSocketChannel  =  dc . channel ( 'net.server.socket' ) ; 
143+   if  ( dc  ===  undefined )  { 
144+     dc  =  require ( 'diagnostics_channel' ) ; 
146145  } 
147146} 
148147
@@ -218,8 +217,8 @@ function connect(...args) {
218217  debug ( 'createConnection' ,  normalized ) ; 
219218  const  socket  =  new  Socket ( options ) ; 
220219  lazyChannels ( ) ; 
221-   if  ( netClientSocketChannel . hasSubscribers )  { 
222-     netClientSocketChannel . publish ( { 
220+   if  ( dc . hasSubscribers ( CLIENT_SOCKET_CHANNEL ) )  { 
221+     dc . publish ( CLIENT_SOCKET_CHANNEL ,   { 
223222      socket, 
224223    } ) ; 
225224  } 
@@ -1762,8 +1761,8 @@ function onconnection(err, clientHandle) {
17621761  socket . _server  =  self ; 
17631762  self . emit ( 'connection' ,  socket ) ; 
17641763  lazyChannels ( ) ; 
1765-   if  ( netServerSocketChannel . hasSubscribers )  { 
1766-     netServerSocketChannel . publish ( { 
1764+   if  ( dc . hasSubscribers ( SERVER_SOCKET_CHANNEL ) )  { 
1765+     dc . publish ( SERVER_SOCKET_CHANNEL ,   { 
17671766      socket, 
17681767    } ) ; 
17691768  } 
0 commit comments