Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Miniflare 3] Use localhost instead of 127.0.0.1 for loopback hostname #615

Merged
merged 1 commit into from
Jun 27, 2023

Conversation

mrbbot
Copy link
Contributor

@mrbbot mrbbot commented Jun 27, 2023

Miniflare starts its loopback server on the same host as the workerd server, so it's accessible on all the same addresses as the runtime. This allows the loopback server to be the target for the live reload web socket. This means if the host: "localhost" option is set, we start a Node http server with localhost as the hostname. Node will perform a DNS lookup to work out which IP address and interface to listen on, but will only listen on the first entry. In Node 17+, this will be the IPv6 interface. Unfortunately, we previously hardcoded the loopback address as the IPv4 loopback, meaning workerd was unable to connect. This change switches to using localhost, which workerd will resolve to either IPv4 or v6.

Closes cloudflare/workers-sdk#3515

Miniflare starts its loopback server on the same host as the
`workerd` server, so it's accessible on all the same addresses as the
runtime. This allows the loopback server to be the target for the
live reload web socket. This means if the `host: "localhost"` option
is set, we start a Node `http` server with `localhost` as the
hostname. Node will perform a DNS lookup to work out which IP address
and interface to listen on, but will only listen on the first entry.
In Node 17+, this will be the IPv6 interface. Unfortunately, we
previously hardcoded the loopback address as the IPv4 loopback,
meaning `workerd` was unable to connect. This change switches to
using `localhost`, which `workerd` will resolve to either IPv4 or v6.

Closes cloudflare/workers-sdk#3515
@mrbbot mrbbot requested a review from a team June 27, 2023 15:55
@changeset-bot
Copy link

changeset-bot bot commented Jun 27, 2023

⚠️ No Changeset found

Latest commit: dbfe5d9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@mrbbot mrbbot changed the title Use localhost instead of 127.0.0.1 for loopback hostname [Miniflare 3] Use localhost instead of 127.0.0.1 for loopback hostname Jun 27, 2023
@mrbbot mrbbot merged commit 79440d7 into tre Jun 27, 2023
@mrbbot mrbbot deleted the bcoll/tre-loopback-localhost branch June 27, 2023 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants