workers-sdk icon indicating copy to clipboard operation
workers-sdk copied to clipboard

fix(miniflare): bypass proxy for local inspector connections

Open Zuckjet opened this issue 1 month ago • 1 comments

Fixes #8906

When users have proxy environment variables set (HTTP_PROXY, HTTPS_PROXY, etc.), the local development server fails to start with a "TypeError: fetch failed" error.

Root cause

  • Wrangler detects proxy environment variables and sets a global ProxyAgent
  • Miniflare's InspectorProxyController makes a fetch request to 127.0.0.1 to connect to the workerd inspector
  • This local request incorrectly goes through the proxy, which typically cannot handle localhost addresses, causing the connection to fail

Solution

Modified InspectorProxyController.updateConnection() to use a dedicated Agent for the local fetch request, bypassing the global proxy settings. Local inspector connections should never be proxied.


  • Tests
    • [ ] Tests included/updated
    • [x] Tests not necessary because: Tested locally with proxy environment variables set
  • Public documentation
    • [ ] Cloudflare docs PR(s):
    • [x] Documentation not necessary because: This should be defalut behavior
  • Wrangler V3 Backport
    • [ ] Wrangler PR:
    • [x] Not necessary because: Not a patch change, not a Wrangler change

Zuckjet avatar Dec 09 '25 06:12 Zuckjet

🦋 Changeset detected

Latest commit: cd09cfe9823b9a7f2d87bff80907b607c91ed95e

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

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

changeset-bot[bot] avatar Dec 09 '25 06:12 changeset-bot[bot]