-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
Expand file tree
/
Copy pathtest-cluster-disconnect-race.js
More file actions
34 lines (26 loc) · 850 Bytes
/
test-cluster-disconnect-race.js
File metadata and controls
34 lines (26 loc) · 850 Bytes
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
28
29
30
31
32
33
34
'use strict';
// This code triggers an AssertionError on Linux in Node.js 5.3.0 and earlier.
// Ref: https://github.com/nodejs/node/issues/4205
var common = require('../common');
var assert = require('assert');
var net = require('net');
var cluster = require('cluster');
cluster.schedulingPolicy = cluster.SCHED_NONE;
if (cluster.isMaster) {
var worker1, worker2;
worker1 = cluster.fork();
worker1.on('message', common.mustCall(function() {
worker2 = cluster.fork();
worker1.disconnect();
worker2.on('online', common.mustCall(worker2.disconnect));
}, 2));
cluster.on('exit', function(worker, code) {
assert.strictEqual(code, 0, 'worker exited with error');
});
return;
}
var server = net.createServer();
server.listen(common.PORT, function retry() {
process.send('listening');
process.send('listening');
});