[node] Restore default Node.js 16 DNS lookup behavior (#163025)

Starting in Node.js 17 the IP address from a DNS lookup resolves in the
order returned from the resolver. Prior versions resolve with IPv4
addresses sorted before IPv6 addresses.

This restores the previous behavior. In distributions, this can be
configured via the `--dns-result-order` flag in `node.options`.

Closes #163006
[Node.js 17
changelog](https://github.com/nodejs/node/blob/main/doc/changelogs/CHANGELOG_V17.md)

[Documentation](https://nodejs.org/docs/latest-v18.x/api/cli.html#--dns-result-orderorder)

Testing

1) Resolve localhost to 127.0.0.1 and then ::1 in `/etc/hosts`
2) `yarn start`. Logs should indicate connecting to elasticsearch over
127.0.0.1:9200
This commit is contained in:
Jon 2023-08-04 08:27:06 -05:00 committed by GitHub
parent 0843781bab
commit bd3b54c51d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

View file

@ -7,3 +7,6 @@
## do not terminate process on unhandled promise rejection
--unhandled-rejections=warn
## restore < Node 16 default DNS lookup behavior
--dns-result-order=ipv4first

View file

@ -8,5 +8,9 @@
// development env setup includes babel/register after the env is initialized
require('./setup_env');
// restore < Node 16 default DNS lookup behavior
require('dns').setDefaultResultOrder('ipv4first');
require('@kbn/babel-register').install();
require('./polyfill');