summaryrefslogtreecommitdiff
path: root/test/parallel/test-cluster-disconnect-suicide-race.js
blob: 15d07002252ee97cbd54d80083bc3f356119813b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
'use strict';

// Test should fail in Node.js 5.4.1 and pass in later versions.

const common = require('../common');
const assert = require('assert');
const cluster = require('cluster');

if (cluster.isMaster) {
  cluster.on('exit', (worker, code) => {
    assert.strictEqual(code, 0, 'worker exited with error');
  });

  return cluster.fork();
}

let eventFired = false;

cluster.worker.disconnect();

process.nextTick(common.mustCall(() => {
  assert.strictEqual(eventFired, false, 'disconnect event should wait for ack');
}));

cluster.worker.on('disconnect', common.mustCall(() => {
  eventFired = true;
}));