| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -425,6 +425,8 @@ Emitted when server receives a request. | |||
| 425 | 425 | ||
| 426 | 426 | Emitted when server sends a response. | |
| 427 | 427 | ||
| 428 | + #### NET | ||
| 429 | + | ||
| 428 | 430 | `net.client.socket` | |
| 429 | 431 | ||
| 430 | 432 | * `socket` {net.Socket} | |
@@ -437,13 +439,40 @@ Emitted when a new TCP or pipe client socket is created. | |||
| 437 | 439 | ||
| 438 | 440 | Emitted when a new TCP or pipe connection is received. | |
| 439 | 441 | ||
| 442 | + #### UDP | ||
| 443 | + | ||
| 440 | 444 | `udp.socket` | |
| 441 | 445 | ||
| 442 | 446 | * `socket` {dgram.Socket} | |
| 443 | 447 | ||
| 444 | 448 | Emitted when a new UDP socket is created. | |
| 445 | 449 | ||
| 450 | + #### Process | ||
| 451 | + | ||
| 452 | + <!-- YAML | ||
| 453 | + added: REPLACEME | ||
| 454 | + --> | ||
| 455 | + | ||
| 456 | + `child_process` | ||
| 457 | + | ||
| 458 | + * `process` {ChildProcess} | ||
| 459 | + | ||
| 460 | + Emitted when a new process is created. | ||
| 461 | + | ||
| 462 | + #### Worker Thread | ||
| 463 | + | ||
| 464 | + <!-- YAML | ||
| 465 | + added: REPLACEME | ||
| 466 | + --> | ||
| 467 | + | ||
| 468 | + `worker_threads` | ||
| 469 | + | ||
| 470 | + * `worker` [`Worker`][] | ||
| 471 | + | ||
| 472 | + Emitted when a new thread is created. | ||
| 473 | + | ||
| 446 | 474 | [`'uncaughtException'`]: process.md#event-uncaughtexception | |
| 475 | + [`Worker`]: worker_threads.md#class-worker | ||
| 447 | 476 | [`channel.subscribe(onMessage)`]: #channelsubscribeonmessage | |
| 448 | 477 | [`diagnostics_channel.channel(name)`]: #diagnostics_channelchannelname | |
| 449 | 478 | [`diagnostics_channel.subscribe(name, onMessage)`]: #diagnostics_channelsubscribename-onmessage | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -59,6 +59,8 @@ const { convertToValidSignal, deprecate } = require('internal/util'); | |||
| 59 | 59 | const { isArrayBufferView } = require('internal/util/types'); | |
| 60 | 60 | const spawn_sync = internalBinding('spawn_sync'); | |
| 61 | 61 | const { kStateSymbol } = require('internal/dgram'); | |
| 62 | + const dc = require('diagnostics_channel'); | ||
| 63 | + const childProcessChannel = dc.channel('child_process'); | ||
| 62 | 64 | ||
| 63 | 65 | const { | |
| 64 | 66 | UV_EACCES, | |
@@ -301,6 +303,11 @@ function ChildProcess() { | |||
| 301 | 303 | ||
| 302 | 304 | maybeClose(this); | |
| 303 | 305 | }; | |
| 306 | + if (childProcessChannel.hasSubscribers) { | ||
| 307 | + childProcessChannel.publish({ | ||
| 308 | + process: this, | ||
| 309 | + }); | ||
| 310 | + } | ||
| 304 | 311 | } | |
| 305 | 312 | ObjectSetPrototypeOf(ChildProcess.prototype, EventEmitter.prototype); | |
| 306 | 313 | ObjectSetPrototypeOf(ChildProcess, EventEmitter); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -87,6 +87,9 @@ let debug = require('internal/util/debuglog').debuglog('worker', (fn) => { | |||
| 87 | 87 | debug = fn; | |
| 88 | 88 | }); | |
| 89 | 89 | ||
| 90 | + const dc = require('diagnostics_channel'); | ||
| 91 | + const workerThreadsChannel = dc.channel('worker_threads'); | ||
| 92 | + | ||
| 90 | 93 | let cwdCounter; | |
| 91 | 94 | ||
| 92 | 95 | const environmentData = new SafeMap(); | |
@@ -260,6 +263,11 @@ class Worker extends EventEmitter { | |||
| 260 | 263 | this[kHandle].startThread(); | |
| 261 | 264 | ||
| 262 | 265 | process.nextTick(() => process.emit('worker', this)); | |
| 266 | + if (workerThreadsChannel.hasSubscribers) { | ||
| 267 | + workerThreadsChannel.publish({ | ||
| 268 | + worker: this, | ||
| 269 | + }); | ||
| 270 | + } | ||
| 263 | 271 | } | |
| 264 | 272 | ||
| 265 | 273 | [kOnExit](code, customErr, customErrReason) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,21 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + const common = require('../common'); | ||
| 3 | + const assert = require('assert'); | ||
| 4 | + const cluster = require('cluster'); | ||
| 5 | + const { ChildProcess } = require('child_process'); | ||
| 6 | + const dc = require('diagnostics_channel'); | ||
| 7 | + | ||
| 8 | + if (cluster.isPrimary) { | ||
| 9 | + dc.subscribe('child_process', common.mustCall(({ process }) => { | ||
| 10 | + assert.strictEqual(process instanceof ChildProcess, true); | ||
| 11 | + })); | ||
| 12 | + const worker = cluster.fork(); | ||
| 13 | + worker.on('online', common.mustCall(() => { | ||
| 14 | + worker.send('disconnect'); | ||
| 15 | + })); | ||
| 16 | + } else { | ||
| 17 | + process.on('message', common.mustCall((msg) => { | ||
| 18 | + assert.strictEqual(msg, 'disconnect'); | ||
| 19 | + process.disconnect(); | ||
| 20 | + })); | ||
| 21 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,11 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + const common = require('../common'); | ||
| 3 | + const assert = require('assert'); | ||
| 4 | + const { Worker } = require('worker_threads'); | ||
| 5 | + const dc = require('diagnostics_channel'); | ||
| 6 | + | ||
| 7 | + dc.subscribe('worker_threads', common.mustCall(({ worker }) => { | ||
| 8 | + assert.strictEqual(worker instanceof Worker, true); | ||
| 9 | + })); | ||
| 10 | + | ||
| 11 | + new Worker('const a = 1;', { eval: true }); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments