Permalink
Browse files

test: fix test-child-process-fork-regr-gh-2847

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 <michael_dawson@ca.ibm.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information...
santigimeno authored and Fishrock123 committed Oct 6, 2016
1 parent 623d3c6 commit 4e9b6a00223b137b0d67e9033a6f311a325df451
Showing with 14 additions and 9 deletions.
  1. +14 −9 test/parallel/test-child-process-fork-regr-gh-2847.js
@@ -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.