Skip to content

Commit d081032

Browse files
batrlaBethGriggs
authored andcommittedMar 27, 2023
test: fix test-net-connect-reset-until-connected
Fixes: #43446 PR-URL: #46781 Reviewed-By: theanarkh <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 086bb2f commit d081032

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed
 

‎test/parallel/parallel.status

-4
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ test-crypto-dh-stateless: SKIP
3434
test-crypto-keygen: SKIP
3535

3636
[$system==solaris] # Also applies to SmartOS
37-
# https://github.com/nodejs/node/issues/43446
38-
test-net-connect-reset-until-connected: PASS, FLAKY
3937
# https://github.com/nodejs/node/issues/43457
4038
test-domain-no-error-handler-abort-on-uncaught-0: PASS, FLAKY
4139
test-domain-no-error-handler-abort-on-uncaught-1: PASS,FLAKY
@@ -55,8 +53,6 @@ test-domain-with-abort-on-uncaught-exception: PASS, FLAKY
5553
test-fs-stat-bigint: PASS,FLAKY
5654
# https://github.com/nodejs/node/issues/31280
5755
test-worker-message-port-message-before-close: PASS,FLAKY
58-
# https://github.com/nodejs/node/issues/43446
59-
test-net-connect-reset-until-connected: PASS, FLAKY
6056

6157
[$system==aix]
6258

‎test/parallel/test-net-connect-reset-until-connected.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,27 @@
33
const common = require('../common');
44
const net = require('net');
55

6+
function barrier(count, cb) {
7+
return function() {
8+
if (--count === 0)
9+
cb();
10+
};
11+
}
12+
613
const server = net.createServer();
714
server.listen(0, common.mustCall(function() {
815
const port = server.address().port;
916
const conn = net.createConnection(port);
17+
const connok = barrier(2, () => conn.resetAndDestroy());
1018
conn.on('close', common.mustCall());
1119
server.on('connection', (socket) => {
20+
connok();
1221
socket.on('error', common.expectsError({
1322
code: 'ECONNRESET',
1423
message: 'read ECONNRESET',
1524
name: 'Error'
1625
}));
1726
server.close();
1827
});
19-
conn.resetAndDestroy();
28+
conn.on('connect', connok);
2029
}));

0 commit comments

Comments
 (0)