test: fix test-net-connect-reset-until-connected
Fixes: https://github.com/nodejs/node/issues/43446 PR-URL: https://github.com/nodejs/node/pull/46781 Reviewed-By: theanarkh <theratliter@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
parent
c1bcdbcf79
commit
21fcfcdd5d
@ -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
|
||||
@ -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
|
||||
|
@ -3,12 +3,21 @@
|
||||
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',
|
||||
@ -16,5 +25,5 @@ server.listen(0, common.mustCall(function() {
|
||||
}));
|
||||
server.close();
|
||||
});
|
||||
conn.resetAndDestroy();
|
||||
conn.on('connect', connok);
|
||||
}));
|
||||
|
Loading…
x
Reference in New Issue
Block a user