Skip to content
Closed
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions lib/cluster.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -48,7 +48,7 @@ Worker.prototype.kill = function() {
};

Worker.prototype.send = function() {
this.process.send.apply(this.process, arguments);
return this.process.send.apply(this.process, arguments);
};

Worker.prototype.isDead = function isDead() {
Expand DownExpand Up@@ -518,7 +518,7 @@ function masterInit() {
}

function send(worker, message, handle, cb) {
sendHelper(worker.process, message, handle, cb);
return sendHelper(worker.process, message, handle, cb);
}
}

Expand DownExpand Up@@ -684,7 +684,7 @@ function workerInit() {
};

function send(message, cb) {
sendHelper(process, message, null, cb);
return sendHelper(process, message, null, cb);
}

function _disconnect(masterInitiated) {
Expand DownExpand Up@@ -732,7 +732,7 @@ function sendHelper(proc, message, handle, cb) {
if (cb) callbacks[seq] = cb;
message.seq = seq;
seq += 1;
proc.send(message, handle);
return proc.send(message, handle);
}


Expand Down
6 changes: 3 additions & 3 deletions lib/internal/child_process.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -504,15 +504,15 @@ function setupChannel(target, channel) {
handle = undefined;
}
if (this.connected) {
this._send(message, handle, false, callback);
return;
return this._send(message, handle, false, callback);
}
const ex = new Error('channel closed');
if (typeof callback === 'function') {
process.nextTick(callback, ex);
} else {
this.emit('error', ex); // FIXME(bnoordhuis) Defer to next tick.
}
return false;
};

target._send = function(message, handle, swallowErrors, callback) {
Expand DownExpand Up@@ -577,7 +577,7 @@ function setupChannel(target, channel) {
handle: null,
message: message,
});
return;
return this._handleQueue.length === 1;
}

var req = new WriteWrap();
Expand Down
9 changes: 9 additions & 0 deletions test/parallel/test-child-process-send-returns-boolean.js
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
'use strict';
const common = require('../common');
const assert = require('assert');
const fork = require('child_process').fork;

const n = fork(common.fixturesDir + '/empty.js');

const rv = n.send({ hello: 'world' });
assert.strictEqual(rv, true);
3 changes: 2 additions & 1 deletion test/parallel/test-cluster-fork-env.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,11 +4,12 @@ var assert = require('assert');
var cluster = require('cluster');

if (cluster.isWorker) {
cluster.worker.send({
const result = cluster.worker.send({
prop: process.env['cluster_test_prop'],
overwrite: process.env['cluster_test_overwrite']
});

assert.strictEqual(result, true);
} else if (cluster.isMaster) {

var checks = {
Expand Down
3 changes: 2 additions & 1 deletion test/parallel/test-cluster-worker-events.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,7 +14,8 @@ if (cluster.isMaster) {
process.exit(0);
});

worker.send('SOME MESSAGE');
const result = worker.send('SOME MESSAGE');
assert.strictEqual(result, true);

return;
}
Expand Down