dns: default to verbatim=true in dns.lookup() #37931
Conversation
|
So, I went again through any single test that failed on my machine and tried to fix it. I found the following tests to fail and did the following to fix them. Let's also have a CI job to see what problems exist on the other setups. Explanations:
|
Explanations: ------------- test/parallel/test-cluster-message.js: add `family: 4` to `connect` because without it will default to `localhost` which could resolve to `::1` if IPv6 is available, while server listen address is hardcoded legacy IPv4. test/parallel/test-http-localaddress.js: add `family: 4,` to `connect` because `localhost` could resolve to `::1` if IPv6 is available, while server listen address is hardcoded legacy IPv4. test/parallel/test-http-upgrade-client.js: add `family: 4,` to `http.get` because `http.get` without specified host uses `localhost` which could resolve to `::1` if IPv6 is available, while server listen address is hardcoded legacy IPv4. test/parallel/test-http2-connect-options.js: add `family: 4` to `http2.connect` `options` because `localhost` might resolve to `::1` if IPv6 is available, causing `EINVAL` when binding to `127.0.0.2`, and server listen address is hardcoded legacy IPv4. test/parallel/test-https-localaddress.js: add `family: 4` to `https.request` `options` because `localhost` might resolve to `::1` if IPv6 is available, causing `EINVAL` when binding to `127.0.0.2`, and server listen address is hardcoded legacy IPv4. test/common/inspector-helper.js: add `family: 4` to `http.get` options to make sure to connect via legacy IPv4 `localhost`, because inspector by default listens on legacy IPv4 `localhost`. Fixes: test/parallel/test-inspect-async-hook-setup-at-inspect.js test/parallel/test-inspector-esm.js test/parallel/test-inspector-inspect-brk-node.js test/parallel/test-inspector-multisession-ws.js test/parallel/test-inspector-reported-host.js test/parallel/test-inspector-wait-for-connection.js test/parallel/test-inspector-waiting-for-disconnect.js test/sequential/test-inspector.js test/sequential/test-inspector-async-hook-setup-at-inspect-brk.js test/sequential/test-inspector-async-hook-setup-at-signal.js test/sequential/test-inspector-async-stack-traces-promise-then.js test/sequential/test-inspector-async-stack-traces-set-interval.js test/sequential/test-inspector-break-e.js test/sequential/test-inspector-break-when-eval.js test/sequential/test-inspector-console.js test/sequential/test-inspector-debug-brk-flag.js test/sequential/test-inspector-debug-end.js test/sequential/test-inspector-exception.js test/sequential/test-inspector-not-blocked-on-idle.js test/sequential/test-inspector-scriptparsed-context.js test/sequential/test-inspector-stop-profile-after-done.js test/sequential/test-inspector-stress-http.js test/parallel/test-net-dns-lookup.js: listen on `common.localhostIPv4` and add `family: 4` to `connect` to force legacy IPv4, because it is required by the assertion tests. Could be changed to DualStack compatibility by using `assert.match(ip, /^(127\.0\.0\.1|::1)$/);` and `assert.match(type.toString, /^(4|6)$/);`. test/parallel/test-net-remote-address-port.js: add `::1` to `remoteAddrCandidates`. Why does this fix it? test/parallel/test-tcp-wrap-listen.js: add ternary test with `hasIPv6` and use `bind` or `bind6` accordingly. test/parallel/test-timers-socket-timeout-removes-other-socket-unref-timer.js: add `family: 4` to `connect` because it will default to localhost being `::1` if IPv6 is available, and listen address is hardcoded to be legacy IPv4 address for `localhost`. test/parallel/test-tls-client-getephemeralkeyinfo.js: add `family: 4` to `connect` because without it will default to `localhost` which could resolve to `::1` if IPv6 is available, while server listen address is hardcoded legacy IPv4. test/parallel/test-tls-client-mindhsize.js: add `family: 4` to `connect` because without it will default to `localhost` which could resolve to `::1` if IPv6 is available, while server listen address is hardcoded legacy IPv4. test/parallel/test-tls-wrap-econnreset-localaddress.js: add `family: 4` to `connect` because without it will default to `localhost` which could resolve to `::1` if IPv6 is available, while server listen address is hardcoded legacy IPv4. test/sequential/test-https-connect-localport.js: remove `family: 4` from connect because listen uses `localhost` which maybe resolves to `::1`? NEEDS TESTING! If it fails --> force legacy IPv4 with `common.localhostIPv4`. test/sequential/test-inspector-open.js: add `family: 4` to `connect` because without it will default to `localhost` which could resolve to `::1` if IPv6 is available, while inspector is listening on legacy IPv4 `localhost` by default. test/sequential/test-net-connect-local-error.js: add `family: 4` to `optionsIPv4` and `family: 6` to `optionsIPv6`, because it seems connecting on IPv4 will default to `localhost` which then resolves to `::1` if IPv6 is available and will cause an error.
|
Alright, so the preliminary results confirm something that I was suspecting. While we could replace Thus, I see two options:
In my opinion, the way to go currently is approach 2. Approach 1 should be something implemented in a separate PR that tries to be more DualStack-aware. In approach 1 it would probably also make sense to review the implementation of DNS resolution on listening and connecting and to make sure they resolve to the same values. |
|
SmartOS fixes:
|
Explanations: test/parallel/test-net-connect-options-port.js: add `family: 4` at various places to force `localhost` or default `localhost` to be resolved to legacy IPv4 addresses. test/parallel/test-net-pingpong.js: change `localhost` to `127.0.0.1` because test is aimed at legacy IPv4, so it can be forced to literal IPv4 address without problem. NEEDS TESTING: does `pingPongTest(0);` pass? test/parallel/test-net-remote-address-port.js: change `localhost` to `127.0.0.1` and force IPv4 by adding `family: 4` because SmartOS will resolve `localhost` or no address automatically to legacy IPv4 address (`127.0.0.1`). test/parallel/test-net-writable.js: listen on `common.localhostIPv4` and add `family: 4` to connect to force IPv4. because SmartOS will resolve `localhost` or no address automatically to legacy IPv4 address (`127.0.0.1`). test/sequential/test-https-connect-localport.js: revert previous change, i.e. readd `family: 4` to `https.get`. Change `localhost` on listen to `common.localhostIPv4` to force legacy IPv4.
|
FWIW I don't think modifying the tests just so they can pass on SmartOS is OK. Depending on the cause of the failure:
Either way, I don't think modifying failing tests is the right thing to do here. @nodejs/platform-smartos wdyt? The changes in bdedf3a LGTM though (thanks for the detailed explanation BTW, that's really good work). |
I think it's both. Refusing to use On the other hand, I don't understand why it is binding fine to
Without the explanations I probably would have lost track myself. It was necessary to have an overview over what needs to be addressed. But thanks for the acknowledgement. |
|
Do the Linux CIs have IPv6 connectivity? Even though I don't really want to admit it...if I remove the public IPv6 address on my system, I observe the same problem as on SmartOS: listening on I am not sure if this is related to the DNS module or to the resolver of the OS. If I do Edit: Thinking a bit about it I think we should adjust the tests. There is the chance (in theory) that having an IPv6 address configured or not might change during runtime. Since we can't listen DualStack on Edit2: It's related to |
|
I think we should ditch On another node, @bnoordhuis also suggested ditching A commit will follow shortly. |
|
Can we get another CI job? |
|
Great! So, what else needs to be discussed now in order to merge this? What should be mentioned in the documentation: usage of |
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
nit: usage of |
|
Ping @nodejs/dns @nodejs/tsc for reviews |
|
CITGM? Sure, why not! |
|
CITGM: https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/2666/ Because many failures are expected and can be ignored, here's a run against master for comparison: CITGM on master: https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/2667/ (queued, will 404 until the job starts, which might not be for a while) |
|
@nodejs/tsc This needs another TSC review. It's a straightforward (but arguably breaking) change. Please take a look? |
Yeah, because tests were crafted in a hacky way by assuming I wonder if it would be better to change the PR in a way to always assume However, in general I feel like this task has grown to an extent where I feel like I can't solve this on my own anymore. If it was for me, I'd simply merge the PR as it is now and let all the maintainers of modules figure out how to make their modules compatible with the internet of today (which is IPv6). There is still LTS and they have plenty of time to adjust. |
Switch the default from false (reorder the result so that IPv4 addresses come before IPv6 addresses) to true (return them exactly as the resolver sent them to us.)
After many tests failed due to differently resolving
localhostto::1or127.0.0.1and after it became impossible to keep track of what worked and what didn't in the CI jobs during running the test suite, this is a fresh start from what we learned in, and effectively a reissue of #37681.Fixes: #31566
Refs: #6307
Refs: #20710
Reissue of #31567