Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 98b721e

Browse filesBrowse files
santigimenoTrott
authored andcommitted
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: #5422 Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent f296a7f commit 98b721e
Copy full SHA for 98b721e

File tree

Expand file treeCollapse file tree

1 file changed

+18
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+18
-2
lines changed
Open diff view settings
Collapse file

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

Copy file name to clipboardExpand all lines: test/parallel/test-child-process-fork-regr-gh-2847.js
+18-2Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@ var server = net.createServer(function(s) {
3232
var s = net.connect(common.PORT, function() {
3333
worker.send({}, s, callback);
3434
});
35+
36+
// Errors can happen if this connection
37+
// is still happening while the server has been closed.
38+
s.on('error', function(err) {
39+
if ((err.code !== 'ECONNRESET') &&
40+
((err.code !== 'ECONNREFUSED'))) {
41+
throw err;
42+
}
43+
});
3544
}
3645

3746
worker.process.once('close', common.mustCall(function() {
@@ -40,7 +49,14 @@ var server = net.createServer(function(s) {
4049
server.close();
4150
}));
4251

43-
// Send 2 handles to make `process.disconnect()` wait
44-
send();
4552
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+
}
61+
});
4662
});

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.