Skip to content

Commit fafffd4

Browse files
santigimenoMyles Borins
authored and
Myles Borins
committed
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 <[email protected]> Reviewed-By: Brian White <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent 3b448a7 commit fafffd4

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

test/parallel/test-child-process-fork-regr-gh-2847.js

+14-9
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,19 @@ var server = net.createServer(function(s) {
4949
server.close();
5050
}));
5151

52-
send();
53-
send(function(err) {
54-
// Ignore errors when sending the second handle because the worker
55-
// may already have exited.
56-
if (err) {
57-
if (err.code !== 'ECONNREFUSED') {
58-
throw err;
59-
}
60-
}
52+
worker.on('online', function() {
53+
send(function(err) {
54+
assert.ifError(err);
55+
send(function(err) {
56+
// Ignore errors when sending the second handle because the worker
57+
// may already have exited.
58+
if (err) {
59+
if ((err.message !== 'channel closed') &&
60+
(err.code !== 'ECONNREFUSED')) {
61+
throw err;
62+
}
63+
}
64+
});
65+
});
6166
});
6267
});

0 commit comments

Comments
 (0)