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 test-net-connect-reset-until-connected #46781

Merged
merged 1 commit into from
Feb 25, 2023
Merged
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
4 changes: 0 additions & 4 deletions test/parallel/parallel.status
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ test-crypto-dh-stateless: SKIP
test-crypto-keygen: SKIP

[$system==solaris] # Also applies to SmartOS
# https://github.com/nodejs/node/issues/43446
test-net-connect-reset-until-connected: PASS, FLAKY
# https://github.com/nodejs/node/issues/43457
test-domain-no-error-handler-abort-on-uncaught-0: PASS, FLAKY
test-domain-no-error-handler-abort-on-uncaught-1: PASS,FLAKY
Expand All @@ -52,8 +50,6 @@ test-domain-with-abort-on-uncaught-exception: PASS, FLAKY
test-fs-stat-bigint: PASS,FLAKY
# https://github.com/nodejs/node/issues/31280
test-worker-message-port-message-before-close: PASS,FLAKY
# https://github.com/nodejs/node/issues/43446
test-net-connect-reset-until-connected: PASS, FLAKY

[$system==ibmi]
# https://github.com/nodejs/node/pull/30819
Expand Down
11 changes: 10 additions & 1 deletion test/parallel/test-net-connect-reset-until-connected.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,27 @@
const common = require('../common');
const net = require('net');

function barrier(count, cb) {
return function() {
if (--count === 0)
cb();
};
}

const server = net.createServer();
server.listen(0, common.mustCall(function() {
const port = server.address().port;
const conn = net.createConnection(port);
const connok = barrier(2, () => conn.resetAndDestroy());
conn.on('close', common.mustCall());
server.on('connection', (socket) => {
connok();
socket.on('error', common.expectsError({
code: 'ECONNRESET',
message: 'read ECONNRESET',
name: 'Error'
}));
server.close();
});
conn.resetAndDestroy();
conn.on('connect', connok);
}));