mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
test: fix flaky child-process-fork-regr-gh-2847
The test is still failing sometimes because when trying to establish the second connection, the server is already closed. Bring back the code that handled this case and was removed in the last refactoring of the test. Also ignore the errors that might happen when sending the second handle to the worker because it may already have exited. PR-URL: https://github.com/nodejs/node/pull/5422 Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
1 parent
97e95d04c2
commit
d681bf24b5
1 file changed
+18
-2
@@ -32,6 +32,15 @@ var server = net.createServer(function(s) {
|
||||
var s = net.connect(common.PORT, function() {
|
||||
worker.send({}, s, callback);
|
||||
});
|
||||
|
||||
// Errors can happen if this connection
|
||||
// is still happening while the server has been closed.
|
||||
s.on('error', function(err) {
|
||||
if ((err.code !== 'ECONNRESET') &&
|
||||
((err.code !== 'ECONNREFUSED'))) {
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
worker.process.once('close', common.mustCall(function() {
|
||||
@@ -40,7 +49,14 @@ var server = net.createServer(function(s) {
|
||||
server.close();
|
||||
}));
|
||||
|
||||
// Send 2 handles to make `process.disconnect()` wait
|
||||
send();
|
||||
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;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user