René's URL Explorer Experiment


Title: fetch() and http.request() disagree when a lower-cased proxy env var is empty · Issue #66202 · nodejs/node · GitHub

Open Graph Title: fetch() and http.request() disagree when a lower-cased proxy env var is empty · Issue #66202 · nodejs/node

X Title: fetch() and http.request() disagree when a lower-cased proxy env var is empty · Issue #66202 · nodejs/node

Description: Version v27.0.0-pre (main, 976a36a) Platform Linux 6.14.0-37-generic x64 Subsystem http What steps will reproduce the bug? Run the script below with a build that has built-in proxy support. It starts a proxy and an origin server, then la...

Open Graph Description: Version v27.0.0-pre (main, 976a36a) Platform Linux 6.14.0-37-generic x64 Subsystem http What steps will reproduce the bug? Run the script below with a build that has built-in proxy support. It star...

X Description: Version v27.0.0-pre (main, 976a36a) Platform Linux 6.14.0-37-generic x64 Subsystem http What steps will reproduce the bug? Run the script below with a build that has built-in proxy support. It star...

Opengraph URL: https://github.com/nodejs/node/issues/66202

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"fetch() and http.request() disagree when a lower-cased proxy env var is empty","articleBody":"### Version\n\nv27.0.0-pre (main, 976a36a5b6c)\n\n### Platform\n\n```text\nLinux 6.14.0-37-generic x64\n```\n\n### Subsystem\n\nhttp\n\n### What steps will reproduce the bug?\n\nRun the script below with a build that has built-in proxy support.\n\nIt starts a proxy and an origin server, then launches a child process that sends one `http.request()` and one `fetch()` using the same proxy environment. The script reports whether each request went through the proxy.\n\n```js\n'use strict';\n\nconst http = require('http');\nconst { spawn } = require('child_process');\nconst { once } = require('events');\n\nconst seen = [];\n\nconst proxy = http.createServer((req, res) => {\n  seen.push(req.url);\n\n  const url = new URL(req.url);\n  http.request({\n    hostname: url.hostname,\n    port: url.port,\n    path: url.pathname,\n  })\n    .on('response', (proxyRes) => proxyRes.pipe(res))\n    .on('error', () => res.end())\n    .end();\n});\n\nconst server = http.createServer((req, res) => res.end('Hello world'));\n\nconst child = `\nconst url = process.env.REQUEST_URL;\n\nrequire('http').get(url + 'request', (res) => {\n  res.resume();\n\n  res.on('end', () => {\n    fetch(url + 'fetch')\n      .then((r) => r.text())\n      .then(\n        () => process.exit(0),\n        () => process.exit(0),\n      );\n  });\n});\n`;\n\n(async () => {\n  proxy.listen(0);\n  server.listen(0);\n\n  await Promise.all([\n    once(proxy, 'listening'),\n    once(server, 'listening'),\n  ]);\n\n  const PROXY = `http://localhost:${proxy.address().port}`;\n  const REQUEST_URL = `http://localhost:${server.address().port}/`;\n\n  const cases = [\n    ['HTTP_PROXY only               ', {\n      HTTP_PROXY: PROXY,\n    }],\n    [\"http_proxy='' HTTP_PROXY=proxy\", {\n      http_proxy: '',\n      HTTP_PROXY: PROXY,\n    }],\n    [\"no_proxy='' NO_PROXY='*'      \", {\n      HTTP_PROXY: PROXY,\n      no_proxy: '',\n      NO_PROXY: '*',\n    }],\n  ];\n\n  for (const [name, env] of cases) {\n    seen.length = 0;\n\n    const childEnv = {\n      ...process.env,\n      NODE_USE_ENV_PROXY: '1',\n      REQUEST_URL,\n    };\n\n    // Avoid inheriting proxy configuration from the machine running\n    // the reproduction.\n    for (const key of [\n      'http_proxy',\n      'HTTP_PROXY',\n      'https_proxy',\n      'HTTPS_PROXY',\n      'no_proxy',\n      'NO_PROXY',\n    ]) {\n      delete childEnv[key];\n    }\n\n    Object.assign(childEnv, env);\n\n    const cp = spawn(process.execPath, ['-e', child], {\n      env: childEnv,\n      stdio: 'ignore',\n    });\n\n    await once(cp, 'exit');\n\n    const via = (tag) =>\n      seen.some((url) => url.endsWith('/' + tag)) ? 'proxy ' : 'direct';\n\n    console.log(\n      `${name}  http.request: ${via('request')}  fetch: ${via('fetch')}`,\n    );\n  }\n\n  proxy.close();\n  server.close();\n})();\n```\n\n### How often does it reproduce? Is there a required condition?\n\nEvery run.\n\nIt requires `NODE_USE_ENV_PROXY=1` (or `--use-env-proxy`) and a lower-cased proxy variable set to the empty string while its upper-cased counterpart is set.\n\nThis does not apply to Windows, where environment variable names are case-insensitive.\n\n### What is the expected behavior? Why is that the expected behavior?\n\n`fetch()` and `http.request()` should interpret the same proxy environment consistently when built-in proxy support is enabled.\n\nWhich interpretation of an empty lower-cased value should be used is a separate question. There are at least two existing behaviors in the ecosystem:\n\n* curl treats an empty lower-cased value as unset and can fall back to the upper-cased variable.\n* Python's `urllib.getproxies_environment()` treats an empty lower-cased value as an override that removes the upper-cased value.\n\nNode.js currently implements both interpretations at once, depending on which client is used.\n\nThe HTTP documentation describes the lower-cased variables as, for example:\n\n> Same as `HTTP_PROXY`. If both are set, `http_proxy` takes precedence.\n\nAn explicitly present empty string makes the intended behavior here ambiguous.\n\n### What do you see instead?\n\n```\nHTTP_PROXY only                 http.request: proxy   fetch: proxy\nhttp_proxy='' HTTP_PROXY=proxy  http.request: proxy   fetch: direct\nno_proxy='' NO_PROXY='*'        http.request: direct  fetch: proxy\n```\n\nThe last two cases disagree, in opposite directions.\n\n### Additional information\n\nThe built-in HTTP implementation uses `||` when selecting between lower- and upper-cased variables:\n\n[`lib/internal/http.js#L206`](https://github.com/nodejs/node/blob/976a36a5b6c/lib/internal/http.js#L206):\n\n```js\nenv.http_proxy || env.HTTP_PROXY\n```\n\n[`lib/internal/http.js#L237`](https://github.com/nodejs/node/blob/976a36a5b6c/lib/internal/http.js#L237):\n\n```js\nenv.no_proxy || env.NO_PROXY\n```\n\nTherefore an empty lower-cased value is falsy and the upper-cased value wins.\n\nUndici's `EnvHttpProxyAgent`, used by `fetch()` through `setupHttpProxy()`, uses nullish coalescing instead:\n\n[`deps/undici/src/lib/dispatcher/env-http-proxy-agent.js#L26`](https://github.com/nodejs/node/blob/976a36a5b6c/deps/undici/src/lib/dispatcher/env-http-proxy-agent.js#L26):\n\n```js\nhttpProxy ?? process.env.http_proxy ?? process.env.HTTP_PROXY\n```\n\nand for `NO_PROXY`:\n\n[`deps/undici/src/lib/dispatcher/env-http-proxy-agent.js#L171`](https://github.com/nodejs/node/blob/976a36a5b6c/deps/undici/src/lib/dispatcher/env-http-proxy-agent.js#L171):\n\n```js\nprocess.env.no_proxy ?? process.env.NO_PROXY ?? ''\n```\n\nTherefore an empty lower-cased value wins on the Undici side.\n\nThe built-in behavior has been present since 036b1fd66d8 added proxy support to `http.request()` in v25.0.0. The reproduction above was only run against the stated build of `main`.\n\nThis appears related to #65616, where `NO_PROXY` matching also differs between `fetch()` and `http.request()`.\n\nIt also relates directly to the still-open item in #57872:\n\n> Share code between the fetch and the http(s) builtin implementation (e.g. env var parsing & matching)\n\nA regression test can demonstrate the inconsistency without deciding which interpretation is correct:\n\n```js\nconst viaRequest = await usesProxy('request', env);\nconst viaFetch = await usesProxy('fetch', env);\n\nassert.strictEqual(viaFetch, viaRequest);\n```\n\nOn current behavior, the empty `http_proxy` and empty `no_proxy` cases fail.\n\nI would be happy to send a PR once it is decided which interpretation built-in proxy support should use consistently.\n\nIf the built-in HTTP behavior is preferred, the corresponding Undici behavior would need to be aligned upstream. If the Undici behavior is preferred, the `||` selections in `lib/internal/http.js` can be changed accordingly. The documentation should then specify how empty values are interpreted.\n\nRefs: [https://github.com/nodejs/node/issues/57872](https://github.com/nodejs/node/issues/57872)","author":{"url":"https://github.com/christianaurichzm","@type":"Person","name":"christianaurichzm"},"datePublished":"2026-09-22T10:29:03Z","url":"https://github.com/nodejs/node/issues/66202"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:4ae7adfa-1d50-431f-e2e4-f7547c74af75
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idA1F8:35BF39:5AAC8A:76B6D3:6AED2AC1
html-safe-nonce5f47f316a5f36254553bc648b64e8b33a99bdefb3ec361078d67ca47ed5d9b66
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMUY4OjM1QkYzOTo1QUFDOEE6NzZCNkQzOjZBRUQyQUMxIiwidmlzaXRvcl9pZCI6IjY3NDcyOTI0OTM0NzU0NTc5MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac9f57e6eed37086c7309ff46c70d23e5bad37b8fa9910d5da5dbd1899c3a17d95
hovercard-subject-tagissue:5538297472
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/66202/issue_layout
twitter:imagehttps://opengraph.githubassets.com/14090dbf218948fee7e65667cece4f6895b89ffd838acddc72a194f94743ace8/nodejs/node/issues/66202
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/14090dbf218948fee7e65667cece4f6895b89ffd838acddc72a194f94743ace8/nodejs/node/issues/66202
og:image:altVersion v27.0.0-pre (main, 976a36a) Platform Linux 6.14.0-37-generic x64 Subsystem http What steps will reproduce the bug? Run the script below with a build that has built-in proxy support. It star...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamechristianaurichzm
hostnamegithub.com
expected-hostnamegithub.com
None9d95365dda0576efe9b71f45807595e396bd0ca9286fba5367a05048e6ddf8f2
turbo-cache-controlno-preview
go-importgithub.com/nodejs/node git https://github.com/nodejs/node.git
octolytics-dimension-user_id9950313
octolytics-dimension-user_loginnodejs
octolytics-dimension-repository_id27193779
octolytics-dimension-repository_nwonodejs/node
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id27193779
octolytics-dimension-repository_network_root_nwonodejs/node
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release98b41fa4b5635ceb45a4c54320fced73817ff290
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/nodejs/node/issues/66202#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F66202
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F66202
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=nodejs%2Fnode
Reloadhttps://github.com/nodejs/node/issues/66202
Reloadhttps://github.com/nodejs/node/issues/66202
Reloadhttps://github.com/nodejs/node/issues/66202
nodejshttps://github.com/nodejs
nodehttps://github.com/nodejs/node
Codehttps://github.com/nodejs/node
Issues656 (656)https://github.com/nodejs/node/issues
Pull requests666 (666)https://github.com/nodejs/node/pulls
Actionshttps://github.com/nodejs/node/actions
Projectshttps://github.com/nodejs/node/projects
Security and qualityhttps://github.com/nodejs/node/security
Insightshttps://github.com/nodejs/node/pulse
https://github.com/nodejs/node
New issuehttps://github.com/login?return_to=https://github.com/nodejs/node/issues/66202
New issuehttps://github.com/login?return_to=https://github.com/nodejs/node/issues/66202
fetch() and http.request() disagree when a lower-cased proxy env var is emptyhttps://github.com/nodejs/node/issues/66202#top
https://github.com/christianaurichzm
christianaurichzmhttps://github.com/christianaurichzm
on Sep 22, 2026https://github.com/nodejs/node/issues/66202#issue-5538297472
976a36ahttps://github.com/nodejs/node/commit/976a36a5b6ce737c9e695f6cde8e141427f13737
lib/internal/http.js#L206https://github.com/nodejs/node/blob/976a36a5b6c/lib/internal/http.js#L206
lib/internal/http.js#L237https://github.com/nodejs/node/blob/976a36a5b6c/lib/internal/http.js#L237
deps/undici/src/lib/dispatcher/env-http-proxy-agent.js#L26https://github.com/nodejs/node/blob/976a36a5b6c/deps/undici/src/lib/dispatcher/env-http-proxy-agent.js#L26
deps/undici/src/lib/dispatcher/env-http-proxy-agent.js#L171https://github.com/nodejs/node/blob/976a36a5b6c/deps/undici/src/lib/dispatcher/env-http-proxy-agent.js#L171
036b1fdhttps://github.com/nodejs/node/commit/036b1fd66d8e18091c826e644aef872aee92ffcc
#65616https://github.com/nodejs/node/issues/65616
#57872https://github.com/nodejs/node/issues/57872
#57872https://github.com/nodejs/node/issues/57872
https://github.com/barathraj048
barathraj048https://github.com/barathraj048
on Sep 22, 2026https://github.com/nodejs/node/issues/66202#issuecomment-5779562657
#57872https://github.com/nodejs/node/issues/57872
https://github.com/christianaurichzm
christianaurichzmhttps://github.com/christianaurichzm
on Sep 22, 2026https://github.com/nodejs/node/issues/66202#issuecomment-5780035987
45c5ec8https://github.com/nodejs/node/commit/45c5ec82a84cce29fbaab5ea10e7d00b9ebf2664
036b1fdhttps://github.com/nodejs/node/commit/036b1fd66d8e18091c826e644aef872aee92ffcc
@joyeecheunghttps://github.com/joyeecheung
#57872https://github.com/nodejs/node/issues/57872
https://github.com/MikeMcC399
MikeMcC399https://github.com/MikeMcC399
on Sep 22, 2026https://github.com/nodejs/node/issues/66202#issuecomment-5784169857
https://github.com/silverwind
silverwindhttps://github.com/silverwind
on Sep 23, 2026https://github.com/nodejs/node/issues/66202#issuecomment-5787189566
https://about.gitlab.com/blog/we-need-to-talk-no-proxy/https://about.gitlab.com/blog/we-need-to-talk-no-proxy/
Sign up for freehttps://github.com/signup?return_to=https://github.com/nodejs/node/issues/66202
Sign in to commenthttps://github.com/login?return_to=https://github.com/nodejs/node/issues/66202
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.