1'use strict'; 2 3// This code triggers an AssertionError on Linux in Node.js 5.3.0 and earlier. 4// Ref: https://github.com/nodejs/node/issues/4205 5 6const common = require('../common'); 7if (common.isWindows) 8 common.skip('This test does not apply to Windows.'); 9 10const assert = require('assert'); 11const net = require('net'); 12const cluster = require('cluster'); 13 14cluster.schedulingPolicy = cluster.SCHED_NONE; 15 16if (cluster.isPrimary) { 17 let worker2; 18 19 const worker1 = cluster.fork(); 20 worker1.on('message', common.mustCall(function() { 21 worker2 = cluster.fork(); 22 worker1.disconnect(); 23 worker2.on('online', common.mustCall(worker2.disconnect)); 24 })); 25 26 cluster.on('exit', common.mustCall(function(worker, code) { 27 assert.strictEqual(code, 0, `worker exited with error code ${code}`); 28 }, 2)); 29 30 return; 31} 32 33const server = net.createServer(); 34 35server.listen(0, function() { 36 process.send('listening'); 37}); 38