feat(proxy): honor http_proxy/https_proxy environment variables - #1107
Open
hsablonniere wants to merge 1 commit into
Open
feat(proxy): honor http_proxy/https_proxy environment variables#1107hsablonniere wants to merge 1 commit into
hsablonniere wants to merge 1 commit into
Conversation
|
🔎 A preview has been automatically published! If you created the alias to the preview script, you can run this command to download and install this preview: clever-preview update feat-proxy-from-envYou can also run it from your local repository: ./scripts/preview.js update feat-proxy-from-env
This preview will be deleted once this PR is closed. |
Open
Node's global fetch() ignores the http_proxy/https_proxy variables, unlike curl, kubectl or s3cmd. Install an EnvHttpProxyAgent (from undici) as the global dispatcher when a proxy variable is set, so every request the CLI makes routes through the proxy and honors no_proxy for exclusions. The dispatcher is only swapped when a proxy is actually configured, leaving the default behavior untouched otherwise. Closes #1050
hsablonniere
force-pushed
the
feat/proxy-from-env
branch
from
June 30, 2026 12:34
8f1b85e to
e7f5c77
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1050
Context
On corporate networks where all outgoing traffic must go through an authenticating HTTP proxy,
cleverfailed withECONNREFUSED. Unlikecurl,kubectlors3cmd, Node's globalfetch()ignores thehttp_proxy/https_proxyenvironment variables by default — so the CLI never used the proxy.The reporter found a workaround (
NODE_USE_ENV_PROXY=1), but that requires users to know a magic variable, only works on recent Node, and emits an experimental warning on some of the versions where it does. We can do better: behave like the other CLI tools and pick up the proxy automatically.Proposal
Install an
EnvHttpProxyAgent(fromundici) as the global dispatcher at startup, so every request the CLI makes (API calls, update checks…) routes through the proxy:http_proxy/https_proxy(and the uppercase variants)no_proxy/NO_PROXYfor exclusionshttp://user:password@host:portDone in
src/initial-setup.jsbecause it must run before the firstfetch().Design decisions
undicidependency +setGlobalDispatcherrather than the nativeNODE_USE_ENV_PROXY=1: the native variable is read at boot only (can't be enabled from JS at runtime), is gated behind Node ≥ ~22.18, and prints an experimental warning. Theundiciroute works at runtime on any supported Node, with no warning, and requires no action from the user.undicipinned to 7.24.4, the same major bundled inside Node 24 → the global-dispatcher symbol is shared with the built-infetch.Stacked on #1106 (upgrade to Node.js 24)
This PR is stacked on #1106: its base branch is
feat/node-24, so the diff above shows only the proxy change. It has been rebased on top of the Node 24 bump.undici@7.24.4requires Node ≥ 20.18.1 and is the same major as theundicibundled in Node 24, so the global-dispatcher symbol is shared with the built-infetch. Merge order: land #1106 first, then this one (GitHub will then retarget the base tomaster).Out of scope
system-gitdeploys: with that feature enabled,clever deploydelegates to the systemgitbinary, which follows its own proxy configuration (git config http.proxy/ its own reading ofhttp_proxy). Not covered here, documented in the README.