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 sequential test-net-connect-local-error #13064

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
23 changes: 9 additions & 14 deletions test/sequential/test-net-connect-local-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,23 @@ const common = require('../common');
const assert = require('assert');
const net = require('net');

// EADDRINUSE is expected to occur on FreeBSD
// Please see https://github.com/nodejs/node/issues/13055 for more details
Copy link
Contributor

Choose a reason for hiding this comment

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

Change to:
Ref: https://github.com/nodejs/node/issues/13055

Copy link
Contributor

Choose a reason for hiding this comment

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

NM. I'll do it.

const expectedErrorCodes = ['ECONNREFUSED', 'EADDRINUSE'];
const client = net.connect({
port: common.PORT + 1,
localPort: common.PORT,
port: common.PORT,
localPort: common.PORT + 1,
localAddress: common.localhostIPv4
});

client.on('error', common.mustCall(function onError(err) {
assert.ok(expectedErrorCodes.includes(err.code));
assert.strictEqual(err.syscall, 'connect');
assert.strictEqual(err.code, 'ECONNREFUSED');
assert.strictEqual(
err.localPort,
common.PORT,
`${err.localPort} !== ${common.PORT} in ${err}`
);
assert.strictEqual(
err.localAddress,
common.localhostIPv4,
`${err.localAddress} !== ${common.localhostIPv4} in ${err}`
);
assert.strictEqual(err.localPort, common.PORT + 1);
assert.strictEqual(err.localAddress, common.localhostIPv4);
assert.strictEqual(
err.message,
`connect ECONNREFUSED ${err.address}:${err.port} ` +
`connect ${err.code} ${err.address}:${err.port} ` +
Copy link
Member

Choose a reason for hiding this comment

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

Are we 100% sure that ECONNREFUSED and EADDRINUSE return the same exact error message other than the err.code and that therefore this line is correct?

Copy link
Contributor

Choose a reason for hiding this comment

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

AFACT they come from the same mechanism.
I tried to stress this, but didn't want to hog the freeBSD machine so only run 50 cycles.
Last time we saw 1 in a 100 give the EADDRINUSE.
So worst case we have a flake and some good comments and bread crumbs to dig further.

`- Local (${err.localAddress}:${err.localPort})`
);
}));