node icon indicating copy to clipboard operation
node copied to clipboard

test: handle EUNATCH on IBM i

Open abmusse opened this issue 2 years ago • 2 comments

Refs: https://github.com/nodejs/node/issues/48049

When IPv6 is disabled IBM i returns EUNATCH (errno 42). For now, I've added an errno check in test case. libuv needs to get updated to handle EUNATCH so that the error code can be addressed as EUNATCH.

This change is related to changes done in https://github.com/nodejs/node/pull/46546

At the time this test case (test-net-autoselectfamily-commandline-option) was not enabled

CC @richardlau CC @nodejs/platform-ibmi

abmusse avatar May 17 '23 20:05 abmusse

@bnoordhuis

I agree the right way is to make libuv handle it.

  1. To my understanding libuv needs to get updated to handle EUNATCH so that the error code can be addressed as EUNATCH. Similar to https://github.com/libuv/libuv/pull/3145

  2. Once EUNATCH is available, I don't know if we want to remap EUNATCH -> ECONNREFUSED though.

abmusse avatar May 18 '23 12:05 abmusse

@bnoordhuis

I've landed a PR to add EUNATCH support in libuv.

abmusse avatar Jun 19 '23 16:06 abmusse

@bnoordhuis @mhdawson @richardlau

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

I've updated the checks to look for EADDRNOTAVAIL or EUNATCH

CC @nodejs/platform-ibmi

abmusse avatar Jul 06 '23 21:07 abmusse

Ping @bnoordhuis

Can you please re-review the latest changes?

abmusse avatar Jul 18 '23 20:07 abmusse

This PR was updated after libuv was updated to 1.46.0. @bnoordhuis does your objection still stand?

richardlau avatar Aug 08 '23 14:08 richardlau

CI: https://ci.nodejs.org/job/node-test-pull-request/53323/

nodejs-github-bot avatar Aug 14 '23 18:08 nodejs-github-bot

@bnoordhuis not sure if you are away, but I think your concerns/comments have been addressed and this is ready to land. If we don't hear back from you by the end of the week I'll assume it's ok to remove your block and proceed.

mhdawson avatar Aug 15 '23 20:08 mhdawson

I'm indeed away. "Gone rock climbing" is intended quite literally but of course I'll take a break from on-siting 7a's for Node.js.

So, I don't believe it's necessary to merge this PR as libuv should be handling it transparently now. Is that not the case?

bnoordhuis avatar Aug 17 '23 10:08 bnoordhuis

Hey @bnoordhuis 👋🏿

This is PR is still needed as libuv now has support for the EUNATCH errno.

The libuv changes:

https://github.com/libuv/libuv/pull/4047

We are not remapping EUNATCH -> ECONNREFUSED.

Before we had test cases simply checking the raw errno e.g.

assert.strictEqual(error.errno, -42);

Now we addresses the issue by checking the error code e.g.

error.code === 'EUNATCH'

This PR adds checks for EUNATCH error code in the spots its raised (when ipv6 is disabled).

We have a failing test case on the IBM i CI that is waiting on the changes from this PR:

https://ci.nodejs.org/job/node-test-commit-ibmi/nodes=ibmi73-ppc64/1256/testReport/(root)/parallel/test_net_autoselectfamily_commandline_option/

abmusse avatar Aug 17 '23 15:08 abmusse

I've dismissed my review because shrug but I wonder why you didn't opt to handle this inside libuv. I assume IBM wants porting to its platforms to be as frictionless as possible.

bnoordhuis avatar Aug 17 '23 20:08 bnoordhuis

I've dismissed my review because shrug but I wonder why you didn't opt to handle this inside libuv. I assume IBM wants porting to its platforms to be as frictionless as possible.

Yes, but it's a hard balance sometimes. EUNATCH represents something different from ECONNREFUSED (or any other errno), and some software behaves appropriately differently when EUNATCH is surfaced.

In this particular case, differentiation of behavior is not needed, but I don't think we want to mask EUNATCH in libuv

ThePrez avatar Aug 17 '23 22:08 ThePrez

ECONNREFUSED is not the correct errno to compare with, since that's used in the case that IPv6 is enabled. The real comparison is with EAFNOSUPPORT and EADDRNOTAVAIL. If we wanted to remap this for "consistency" then, which should we choose? POSIX errnos are already kind of a mess of inconsistencies and libuv returning it directly basically pushes that on to the consumer. I'm not sure why we should remap EUNATACH for this one case when libuv doesn't do that for EAFNOSUPPORT or EADDRNOTAVAIL already (and likely in other circumstances).

kadler avatar Aug 18 '23 16:08 kadler

ECONNREFUSED is not the correct errno to compare with [..] not sure why we should remap EUNATACH for this one case when libuv doesn't do that for EAFNOSUPPORT or EADDRNOTAVAIL already

My point wasn't that ECONNREFUSED is the best error to report, I just picked it as an example.

EUNATACH is an exotic error (not widely available and rare even on systems that report it) and therefore it's better to map it to something more mundane like EADDRNOTAVAIL.

There's a decent chance a libuv user has logic for handling EADDRNOTAVAIL but EUNATACH? No way.

bnoordhuis avatar Aug 19 '23 10:08 bnoordhuis

@abmusse let me know once you have addressed @kadler's comments and the PR is ready to land.

mhdawson avatar Aug 22 '23 14:08 mhdawson

@mhdawson

Yes I've addressed Kevin's comments in https://github.com/nodejs/node/pull/48050/commits/f83b1021341d5e9ddc3ea5e590d947e4e85d5703

abmusse avatar Aug 22 '23 14:08 abmusse

CI: https://ci.nodejs.org/job/node-test-pull-request/53495/

nodejs-github-bot avatar Aug 22 '23 15:08 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/53523/

nodejs-github-bot avatar Aug 23 '23 14:08 nodejs-github-bot

Landed in ee1f609a9e1b

mhdawson avatar Aug 23 '23 18:08 mhdawson