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.
  • Loading branch information
abmusse committed Jul 6, 2023
1 parent d9438cc commit 09207b8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 17 deletions.
5 changes: 2 additions & 3 deletions test/parallel/test-net-autoselectfamily-commandline-option.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +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 {
assert.strictEqual(error.code, 'EADDRNOTAVAIL');
assert.strictEqual(error.message, `connect EADDRNOTAVAIL ::1:${port} - Local (:::0)`);
} else if (error.code === 'EADDRNOTAVAIL' || error.code === 'EUNATCH') {
assert.strictEqual(error.message, `connect ${error.code} ::1:${port} - Local (:::0)`);
}

ipv4Server.close();
Expand Down
9 changes: 2 additions & 7 deletions test/parallel/test-net-autoselectfamily-default.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +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 {
assert.strictEqual(error.code, 'EADDRNOTAVAIL');
assert.strictEqual(error.message, `connect EADDRNOTAVAIL ::1:${port} - Local (:::0)`);
} else if (error.code === 'EADDRNOTAVAIL' || error.code === 'EUNATCH') {
assert.strictEqual(error.message, `connect ${error.code} ::1:${port} - Local (:::0)`);
}

ipv4Server.close();
Expand Down
9 changes: 2 additions & 7 deletions test/parallel/test-net-autoselectfamily.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,13 +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 {
assert.strictEqual(error.code, 'EADDRNOTAVAIL');
assert.strictEqual(error.message, `connect EADDRNOTAVAIL ::1:${port} - Local (:::0)`);
} else if (error.code === 'EADDRNOTAVAIL' || error.code === 'EUNATCH') {
assert.strictEqual(error.message, `connect ${error.code} ::1:${port} - Local (:::0)`);
}

ipv4Server.close();
Expand Down

0 comments on commit 09207b8

Please sign in to comment.