Skip to content

Commit cf0130d

Browse files
committed
lib: return boolean from child.send()
Previous change reinstated returning boolean from child.send() but missed one instance where undefined might be returned instead. PR-URL: #3577 Reviewed-By: Ben Noordhuis <[email protected]>
1 parent d995b72 commit cf0130d

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

lib/internal/child_process.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ function setupChannel(target, channel) {
551551
handle: handle,
552552
message: message.msg,
553553
});
554-
return;
554+
return this._handleQueue.length === 1;
555555
}
556556

557557
var obj = handleConversion[message.type];
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,29 @@
11
'use strict';
22
const common = require('../common');
33
const assert = require('assert');
4+
const path = require('path');
5+
const net = require('net');
46
const fork = require('child_process').fork;
7+
const spawn = require('child_process').spawn;
58

6-
const n = fork(common.fixturesDir + '/empty.js');
9+
const emptyFile = path.join(common.fixturesDir, 'empty.js');
10+
11+
const n = fork(emptyFile);
712

813
const rv = n.send({ hello: 'world' });
914
assert.strictEqual(rv, true);
15+
16+
const spawnOptions = { stdio: ['pipe', 'pipe', 'pipe', 'ipc'] };
17+
const s = spawn(process.execPath, [emptyFile], spawnOptions);
18+
var handle = null;
19+
s.on('exit', function() {
20+
handle.close();
21+
});
22+
23+
net.createServer(common.fail).listen(common.PORT, function() {
24+
handle = this._handle;
25+
assert.strictEqual(s.send('one', handle), true);
26+
assert.strictEqual(s.send('two', handle), true);
27+
assert.strictEqual(s.send('three'), false);
28+
assert.strictEqual(s.send('four'), false);
29+
});

0 commit comments

Comments
 (0)