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: move net reconnect error test to sequential #13033

Closed
wants to merge 1 commit into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,19 @@ const N = 20;
let client_error_count = 0;
let disconnect_count = 0;

// Hopefully nothing is running on common.PORT
const c = net.createConnection(common.PORT);

c.on('connect', common.mustNotCall('client should not have connected'));

c.on('error', function(e) {
console.error(`CLIENT error: ${e.code}`);
c.on('error', common.mustCall((e) => {
client_error_count++;
assert.strictEqual('ECONNREFUSED', e.code);
});
}, N + 1));

c.on('close', function() {
console.log('CLIENT disconnect');
c.on('close', common.mustCall(() => {
if (disconnect_count++ < N)
c.connect(common.PORT); // reconnect
});
}, N + 1));

process.on('exit', function() {
assert.strictEqual(N + 1, disconnect_count);
Expand Down