Skip to content
This repository has been archived by the owner on Oct 16, 2021. It is now read-only.

Commit

Permalink
test: fix test-child-process-fork-regr-nodejsgh-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: nodejs/node#8950
PR-URL: nodejs/node#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 Myles Borins committed Nov 22, 2016
1 parent 3b448a7 commit fafffd4
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 fafffd4

Please sign in to comment.