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

Change default ip for dev server from 0.0.0.0 to * #4307

Merged
merged 2 commits into from
Nov 9, 2023
Merged

Conversation

jspspike
Copy link
Contributor

@jspspike jspspike commented Oct 30, 2023

This provides support for ipv6 with wrangler dev

Fixes #3732

Author has addressed the following:

  • Tests
    • Included
    • Not necessary because:
  • Changeset (Changeset guidelines)
    • Included
    • Not necessary because:
  • Associated docs
    • Issue(s)/PR(s):
    • Not necessary because:

Note for PR author:

We want to celebrate and highlight awesome PR review! If you think this PR received a particularly high-caliber review, please assign it the label highlight pr review so future reviewers can take inspiration and learn from it.

@jspspike jspspike requested a review from a team as a code owner October 30, 2023 16:27
@changeset-bot
Copy link

changeset-bot bot commented Oct 30, 2023

🦋 Changeset detected

Latest commit: aa53ab4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
wrangler Patch
miniflare Patch
@cloudflare/pages-shared Patch

Not sure what this means? Click here to learn what changesets are.

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

@codecov
Copy link

codecov bot commented Oct 30, 2023

Codecov Report

Merging #4307 (aa53ab4) into main (3cf120c) will increase coverage by 0.18%.
Report is 2 commits behind head on main.
The diff coverage is 23.52%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    cloudflare/workers-sdk#4307      +/-   ##
==========================================
+ Coverage   75.28%   75.46%   +0.18%     
==========================================
  Files         223      225       +2     
  Lines       12357    12449      +92     
  Branches     3198     3227      +29     
==========================================
+ Hits         9303     9395      +92     
  Misses       3054     3054              
Files Coverage Δ
packages/wrangler/src/config/validation.ts 90.09% <100.00%> (ø)
packages/wrangler/src/dev/remote.tsx 8.24% <ø> (ø)
packages/wrangler/src/https-options.ts 100.00% <100.00%> (ø)
packages/wrangler/src/dev/proxy.ts 4.51% <7.14%> (-0.07%) ⬇️

... and 6 files with indirect coverage changes

@github-actions
Copy link
Contributor

github-actions bot commented Oct 30, 2023

A wrangler prerelease is available for testing. You can install this latest build in your project with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/6814508044/npm-package-wrangler-4307

You can reference the automatically updated head of this PR with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/6814508044/npm-package-wrangler-4307

Or you can use npx with this latest build directly:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/6814508044/npm-package-wrangler-4307 dev path/to/script.js
Additional artifacts:
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/6814508044/npm-package-miniflare-4307
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/6814508044/npm-package-cloudflare-pages-shared-4307

Note that these links will no longer work once the GitHub Actions artifact expires.


wrangler@3.15.0 includes the following runtime dependencies:

Package Constraint Resolved
miniflare workspace:* 3.20231025.1
workerd 1.20231030.0 1.20231030.0
workerd --version 1.20231030.0 2023-10-30

|

Please ensure constraints are pinned, and miniflare/workerd minor versions match.

@Cherry
Copy link
Contributor

Cherry commented Oct 30, 2023

Testing this, I get the following output on my windows system now:

(don't mind the error, that's cloudflare/workerd#1408)

[mf:inf] Ready on http://*:8787
[mf:inf] - http://[2606:4700:110:8da6:bb53:5d3e:ac67:334e]:8787
[mf:inf] - http://[fe80::ea19:d284:e881:ca23]:8787
[mf:inf] - http://192.168.50.240:8787
[mf:inf] - http://[::1]:8787
[mf:inf] - http://127.0.0.1:8787
[mf:inf] - http://[fe80::c991:30fc:6720:d91e]:8787
[mf:inf] - http://172.24.144.1:8787

That's a lot of visual output - is there perhaps a better way to present this if there's going to be that many bind addresses to print moving forward?

@jspspike
Copy link
Contributor Author

@Cherry This was discussed with the team previously when adding similar functionality to miniflare. We decided that showing all of them once initially would be helpful but if reviewers feel differently now we can discuss

@jspspike
Copy link
Contributor Author

@Cherry After discussing with the team we thought it would be best to remove the ipv6 addresses from the printout

That will require a change in miniflare so this PR is blocked until that is released

@jspspike jspspike marked this pull request as draft October 31, 2023 16:06
@jspspike jspspike marked this pull request as ready for review November 8, 2023 19:08
for (const accessibleHost of accessibleHosts) {
logger.log(`- ${localProtocol}://${accessibleHost}:${usedPort}`);
}
});
proxy.server.listen(port, ip);

proxy.server.listen(port, ip === "*" ? "::" : ip);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does :: always work? Can a user configure their computer to prevent IPV6?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% sure, looks like you can disable ipv6 on a computer so I'll test manually and see what happens

Copy link
Contributor Author

@jspspike jspspike Nov 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After testing with

sysctl -w net.ipv6.conf.all.disable_ipv6=1
sysctl -w net.ipv6.conf.default.disable_ipv6=1

on linux it seems to still be able to listen on ipv4 addresses

Copy link
Contributor

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM assuming that listening on :: always works on all machines.

Also support ipv6 for dev server
@jspspike jspspike merged commit 7fbe193 into main Nov 9, 2023
17 checks passed
@jspspike jspspike deleted the jspspike/dev-host branch November 9, 2023 18:15
@workers-devprod workers-devprod mentioned this pull request Nov 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

🐛 BUG: wrangler dev listens only on ipv4 localhost, not ipv6
3 participants