-
Notifications
You must be signed in to change notification settings - Fork 791
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
fix: add warning to fetch()
calls that will change the requested port
#992
fix: add warning to fetch()
calls that will change the requested port
#992
Conversation
🦋 Changeset detectedLatest commit: 5464941 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
A wrangler prerelease is available for testing. You can install this latest build in your project with: npm install --save-dev https://prerelease-registry.developers.workers.dev/runs/2575542454/npm-package-wrangler-992 You can reference the automatically updated head of this PR with: npm install --save-dev https://prerelease-registry.developers.workers.dev/prs/992/npm-package-wrangler-992 Or you can use npx https://prerelease-registry.developers.workers.dev/runs/2575542454/npm-package-wrangler-992 dev path/to/script.js |
b058786
to
65ad2fc
Compare
If you are interested in testing this locally, you can try adding the following fetch requests to a Worker and running await fetch("http://portquiz.net");
await fetch("https://portquiz.takao-tech.com");
await fetch("http://portquiz.net:8989");
await fetch("https://portquiz.takao-tech.com:8989");
await fetch("http://portquiz.net");
await fetch("https://portquiz.takao-tech.com");
await fetch("http://portquiz.net:8988");
await fetch("https://portquiz.takao-tech.com:8988");
await fetch("http://portquiz.net");
await fetch("https://portquiz.takao-tech.com");
await fetch("http://portquiz.net:8989");
await fetch("https://portquiz.takao-tech.com:8989"); |
In Workers published to the Edge (rather than previews) there is a bug where a custom port on a downstream fetch request is ignored, defaulting to the standard port. For example, `https://my.example.com:668` will actually send the request to `https://my.example.com:443`. This does not happen when using `wrangler dev` (both in remote and local mode), but to ensure that developers are aware of it this change displays a runtime warning in the console when the bug is hit. Closes cloudflare#1320
65ad2fc
to
5464941
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Been looking forward to this one. This is the sort of thing wrangler should be doing, adds real value to using it. Thank you very much!
Yeah good point. I reopened the issue, let's close it only once we ship the fix in the runtime. |
In #992, we added a dev-only helper that would warn when using `fetch()` in a manner that wouldn't work as expected (because of a bug we currently have in the runtime). We did this by injecting a file that would override usages of `fetch()`. When using pnp style package managers like yarn, this file can't be resolved correctly. So to fix that, we extract it into the temporary destination directory that we use to build the worker (much like a similar fix we did in #1154) Reported at #1320 (comment)
In #992, we added a dev-only helper that would warn when using `fetch()` in a manner that wouldn't work as expected (because of a bug we currently have in the runtime). We did this by injecting a file that would override usages of `fetch()`. When using pnp style package managers like yarn, this file can't be resolved correctly. So to fix that, we extract it into the temporary destination directory that we use to build the worker (much like a similar fix we did in #1154) Reported at #1320 (comment)
In Workers published to the Edge (rather than previews) there is a bug where a custom port on a downstream fetch request is ignored, defaulting to the standard port.
For example,
https://my.example.com:668
will actually send the request tohttps://my.example.com:443
.This does not happen when using
wrangler dev
(both in remote and local mode), but to ensure that developers are aware of it this change displays a runtime warning in the console when the bug is hit.Closes #1320