Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow specifying hostname for Hapi servers.
And specify it as "localhost" for the servers that are started by the integration tests. Some of the integration tests were failing for me because: - My laptop is configured with both IPv4 and IPv6 for localhost (and non-localhost, too, but that's not relevant here). - Hapi binds to 0.0.0.0 by default ([API docs](https://hapi.dev/api/?v=20.2.2#-serveroptionsaddress), [code reference](https://github.com/hapijs/hapi/blob/b8ba0adc7c3255995cb56a9a740c4f9750b80e6b/lib/core.js#L339)). - That's an IPv4 address so the server will only accept connections over IPv4 and not IPv6. - Our integration test config specifies `localhost` when creating the clients for connecting to these servers. - `localhost` can resolve to an IPv6 address. - Node before v17 sorted IP addresses from the name resolver so IPv4 addresses were first but Node v17 and newer returns them in the order returned by the resolver ([GitHub comment](nodejs/node#40537 (comment)), [relevant PR](nodejs/node#39987), it's the first "Other Notable Changes" in [the v17.0.0 release notes](https://nodejs.org/en/blog/release/v17.0.0/#other-notable-changes)). Apparently on my laptop an IPv6 address is returned before an IPv4 address. Alternatively I could have changed the test config so clients connect to 127.0.0.1. I like this change because: - It's a good idea to allow users to specify the address to bind to. - Now the test servers will bind to localhost instead of 0.0.0.0 and it's nice to avoid accepting outside connections when possible.
- Loading branch information