Skip to content

Commit

Permalink
test: handle EUNATCH
Browse files Browse the repository at this point in the history
When IPv6 is disabled IBM i returns EUNATCH (errno 42)
instead of EADDRNOTAVAIL.

libuv 1.46.0 adds EUNATCH errno

We can now use error.code to refer to EUNATCH
in node versions that use libuv 1.46.0.

PR-URL: #48050
Refs: #48049
Refs: #46546
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
  • Loading branch information
abmusse authored and mhdawson committed Aug 23, 2023
1 parent e74d1b8 commit ee1f609
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
2 changes: 2 additions & 0 deletions test/parallel/test-net-autoselectfamily-commandline-option.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ function createDnsServer(ipv6Addr, ipv4Addr, cb) {
assert.strictEqual(error.message, `connect ECONNREFUSED ::1:${port}`);
} else if (error.code === 'EAFNOSUPPORT') {
assert.strictEqual(error.message, `connect EAFNOSUPPORT ::1:${port} - Local (undefined:undefined)`);
} else if (error.code === 'EUNATCH') {
assert.strictEqual(error.message, `connect EUNATCH ::1:${port} - Local (:::0)`);
} else {
assert.strictEqual(error.code, 'EADDRNOTAVAIL');
assert.strictEqual(error.message, `connect EADDRNOTAVAIL ::1:${port} - Local (:::0)`);
Expand Down
6 changes: 2 additions & 4 deletions test/parallel/test-net-autoselectfamily-default.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,8 @@ function createDnsServer(ipv6Addr, ipv4Addr, cb) {
assert.strictEqual(error.message, `connect ECONNREFUSED ::1:${port}`);
} else if (error.code === 'EAFNOSUPPORT') {
assert.strictEqual(error.message, `connect EAFNOSUPPORT ::1:${port} - Local (undefined:undefined)`);
} else if (common.isIBMi) {
// IBMi returns EUNATCH (ERRNO 42) when IPv6 is disabled
// keep this errno assertion until EUNATCH is recognized by libuv
assert.strictEqual(error.errno, -42);
} else if (error.code === 'EUNATCH') {
assert.strictEqual(error.message, `connect EUNATCH ::1:${port} - Local (:::0)`);
} else {
assert.strictEqual(error.code, 'EADDRNOTAVAIL');
assert.strictEqual(error.message, `connect EADDRNOTAVAIL ::1:${port} - Local (:::0)`);
Expand Down
6 changes: 2 additions & 4 deletions test/parallel/test-net-autoselectfamily.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,8 @@ if (common.hasIPv6) {
assert.strictEqual(error.message, `connect ECONNREFUSED ::1:${port}`);
} else if (error.code === 'EAFNOSUPPORT') {
assert.strictEqual(error.message, `connect EAFNOSUPPORT ::1:${port} - Local (undefined:undefined)`);
} else if (common.isIBMi) {
// IBMi returns EUNATCH (ERRNO 42) when IPv6 is disabled
// keep this errno assertion until EUNATCH is recognized by libuv
assert.strictEqual(error.errno, -42);
} else if (error.code === 'EUNATCH') {
assert.strictEqual(error.message, `connect EUNATCH ::1:${port} - Local (:::0)`);
} else {
assert.strictEqual(error.code, 'EADDRNOTAVAIL');
assert.strictEqual(error.message, `connect EADDRNOTAVAIL ::1:${port} - Local (:::0)`);
Expand Down

0 comments on commit ee1f609

Please sign in to comment.