Skip to content

Commit 9352c19

Browse files
committed
child_process: don't emit same handle twice
It's possible to read multiple messages off the parent/child channel. When that happens, make sure that recvHandle is cleared after emitting the first message so it doesn't get emitted twice.
1 parent cfd0dca commit 9352c19

2 files changed

Lines changed: 2 additions & 0 deletions

File tree

lib/child_process.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ function setupChannel(target, channel) {
337337
var message = JSON.parse(json);
338338

339339
handleMessage(target, message, recvHandle);
340+
recvHandle = undefined;
340341

341342
start = i + 1;
342343
}

test/simple/test-child-process-fork-getconnections.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ if (process.argv[2] === 'child') {
3535
}
3636

3737
if (m.cmd === 'close') {
38+
assert.equal(socket, undefined);
3839
sockets[m.id].once('close', function() {
3940
process.send({ id: m.id, status: 'closed' });
4041
});

0 commit comments

Comments
 (0)