Skip to content

Cluster can not kill worker if work's event loop is blockedΒ #22703

Closed
@killagu

Description

@killagu
  • Version: *
  • Platform: *
  • Subsystem: cluster

When worker event loop is blocked, it can not disconnect from the master. So the proc.kill will not be executed.

The SIGTERM can not work is good for me. I wish SIGKILL will work in this scenario as the doc.

'SIGKILL' cannot have a listener installed, it will unconditionally terminate Node.js on all platforms.

And here is the code.

'use strict';

const cluster = require('cluster');
const assert = require('assert');
const isMaster = cluster.isMaster;

if (isMaster) {
  const worker = cluster.fork();
  setTimeout(() => {
    worker.kill('SIGKILL'); // worker.process.kill('SIGKILL');
  }, 1000);
  worker.on('exit', () => {
    console.log('worker exit');
  })
} else {
  let i = 2;
  while(true) {
    i = i % 2;
  }
}

worker.process.kill works, but looks like odd.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clusterIssues and PRs related to the cluster subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions