Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions test/parallel/test-cluster-send-handle-twice.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
'use strict';
// Testing to send an handle twice to the parent process.

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

var workers = {
const workers = {
toStart: 1
};

if (cluster.isMaster) {
for (var i = 0; i < workers.toStart; ++i) {
var worker = cluster.fork();
worker.on('exit', function(code, signal) {
for (let i = 0; i < workers.toStart; ++i) {
const worker = cluster.fork();
worker.on('exit', common.mustCall(function(code, signal) {
assert.strictEqual(code, 0, 'Worker exited with an error code');
assert(!signal, 'Worker exited by a signal');
});
assert.strictEqual(signal, null, 'Worker exited by a signal');
}));
}
} else {
var server = net.createServer(function(socket) {
const server = net.createServer(function(socket) {
process.send('send-handle-1', socket);
process.send('send-handle-2', socket);
});

server.listen(common.PORT, function() {
var client = net.connect({ host: 'localhost', port: common.PORT });
client.on('close', function() { cluster.worker.disconnect(); });
const client = net.connect({ host: 'localhost', port: common.PORT });
client.on('close', common.mustCall(() => { cluster.worker.disconnect(); }));
setTimeout(function() { client.end(); }, 50);
}).on('error', function(e) {
console.error(e);
assert(false, 'server.listen failed');
common.fail('server.listen failed');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This bug was in the original test, but the next line will never execute because common.fail() (and, in the existing test, assert(false, ...)) result in the termination of the program.

cluster.worker.disconnect();
});
}