Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion test/parallel/parallel.status
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ test-tick-processor : PASS,FLAKY

[$system==linux]
test-tick-processor : PASS,FLAKY
test-child-process-fork-regr-gh-2847 : PASS,FLAKY

[$system==macos]

Expand Down
35 changes: 3 additions & 32 deletions test/parallel/test-child-process-fork-regr-gh-2847.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ const assert = require('assert');
const cluster = require('cluster');
const net = require('net');

var connectcount = 0;
var sendcount = 0;

if (!cluster.isMaster) {
// Exit on first received handle to leave the queue non-empty in master
process.on('message', function() {
Expand All @@ -18,13 +15,6 @@ if (!cluster.isMaster) {
}

var server = net.createServer(function(s) {
if (common.isWindows) {
s.on('error', function(err) {
// Prevent possible ECONNRESET errors from popping up
if (err.code !== 'ECONNRESET' || sendcount === 0)
throw err;
});
}
setTimeout(function() {
s.destroy();
}, 100);
Expand All @@ -34,21 +24,6 @@ var server = net.createServer(function(s) {
function send(callback) {
var s = net.connect(common.PORT, function() {
worker.send({}, s, callback);
connectcount++;
});

// Errors can happen if the connections
// are still happening while the server has been closed.
// This can happen depending on how the messages are
// bundled into packets. If they all make it into the first
// one then no errors will occur, otherwise the server
// may have been closed by the time the later ones make
// it to the server side.
// We ignore any errors that occur after some connections
// get through
s.on('error', function(err) {
if (connectcount < 3)
console.log(err);
});
}

Expand All @@ -58,11 +33,7 @@ var server = net.createServer(function(s) {
server.close();
}));

// Queue up several handles, to make `process.disconnect()` wait
for (var i = 0; i < 100; i++)
send(function(err) {
if (err && sendcount < 3)
console.log(err);
sendcount++;
});
// Send 2 handles to make `process.disconnect()` wait
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this comment. Where does the test call process.disconnect()?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bnoordhuis The original version of that comment landed in 36b969f and was authored by @indutny. I think it might be referring to target.disconnect() being called in lib/internal/child_process.js in channel.onread() but I'm not actually sure.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, what @Trott says. It was in the original version of the test. I can try to find out the reason

send();
send();
});