| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -134,6 +134,22 @@ const isWindows = process.platform === 'win32'; | |||
| 134 | 134 | const noop = () => {}; | |
| 135 | 135 | ||
| 136 | 136 | const 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 | + | ||
| 137 | 153 | const { | |
| 138 | 154 | hasObserver, | |
| 139 | 155 | startPerf, | |
@@ -205,7 +221,7 @@ function connect(...args) { | |||
| 205 | 221 | const options = normalized[0]; | |
| 206 | 222 | debug('createConnection', normalized); | |
| 207 | 223 | const socket = new Socket(options); | |
| 208 | - | ||
| 224 | + lazyChannels(); | ||
| 209 | 225 | if (options.timeout) { | |
| 210 | 226 | socket.setTimeout(options.timeout); | |
| 211 | 227 | } | |
@@ -1737,6 +1753,7 @@ function onconnection(err, clientHandle) { | |||
| 1737 | 1753 | ||
| 1738 | 1754 | DTRACE_NET_SERVER_CONNECTION(socket); | |
| 1739 | 1755 | self.emit('connection', socket); | |
| 1756 | + lazyChannels(); | ||
| 1740 | 1757 | } | |
| 1741 | 1758 | ||
| 1742 | 1759 | /** | |
| Back | FazBrowse Home | New Git URL |
0 commit comments