Skip to content

lib: fix listen with handle in cluster worker

  1. fork a process by cluster.fork.
  2. call net.createServer().listen(handle) in worker.
  3. the worker will pass some invalid parameters to main process by calling cluster._getServer.
  4. throw an error in main process when try to create a handle or server.

the error is as follows.

TypeError [ERR_INVALID_ARG_VALUE]: The argument 'options' is invalid. Received {
  path: null,
  backlog: 0,
  readableAll: undefined,
  writableAll: undefined
}
    at new NodeError (node:internal/errors:405:5)
    at Server.listen (node:net:2016:9)
    at new RoundRobinHandle (node:internal/cluster/round_robin_handle:36:17)
    at queryServer (node:internal/cluster/primary:298:16)
    at Worker.onmessage (node:internal/cluster/primary:254:5)
    at ChildProcess.onInternalMessage (node:internal/cluster/utils:49:5)
    at ChildProcess.emit (node:events:523:35)
    at emit (node:internal/child_process:944:14)
    at process.processTicksAndRejections (node:internal/process/task_queues:83:21) 

I think it should not call cluster._getServer in this scenario(listen with handle).

  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

Merge request reports

Loading