Skip to content

Commit

Permalink
test: fix test-child-process-fork-regr-gh-2847
Browse files Browse the repository at this point in the history
It's not guaranteed that the first socket that tries to connect is the
first that succeeds so the rest of assumptions made in the test are not
correct.
Fix it by making sure the second socket does not try to connect until
the first has succeeded.
The IPC channel can already be closed when sending the second socket. It
should be allowed.
Also, don't start sending messages until the worker is online.

Fixes: #8950
PR-URL: #8954
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Brian White <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
  • Loading branch information
santigimeno authored and Fishrock123 committed Oct 11, 2016
1 parent 623d3c6 commit 4e9b6a0
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions test/parallel/test-child-process-fork-regr-gh-2847.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,19 @@ var server = net.createServer(function(s) {
server.close();
}));

send();
send(function(err) {
// Ignore errors when sending the second handle because the worker
// may already have exited.
if (err) {
if (err.code !== 'ECONNREFUSED') {
throw err;
}
}
worker.on('online', function() {
send(function(err) {
assert.ifError(err);
send(function(err) {
// Ignore errors when sending the second handle because the worker
// may already have exited.
if (err) {
if ((err.message !== 'channel closed') &&
(err.code !== 'ECONNREFUSED')) {
throw err;
}
}
});
});
});
});

0 comments on commit 4e9b6a0

Please sign in to comment.