fix: respect HTTP_PROXY/HTTPS_PROXY environment variables#363
fix: respect HTTP_PROXY/HTTPS_PROXY environment variables#363kerrypotter wants to merge 2 commits intoopenclaw:mainfrom
Conversation
The CLI creates a custom undici Agent via setGlobalDispatcher() which overrides any proxy configuration. Since Node.js native fetch (backed by undici) does not automatically respect HTTP_PROXY/HTTPS_PROXY env vars, the CLI fails with 'fetch failed' on systems that require a proxy for outbound connections. Import ProxyAgent from undici and use it when any of the standard proxy environment variables (HTTPS_PROXY, HTTP_PROXY, https_proxy, http_proxy) is set. When no proxy variable is present, behavior is unchanged. Also adds proxy documentation to cli.md and a troubleshooting entry.
|
Someone is attempting to deploy a commit to the Amantus Machina Team on Vercel. A member of the Team first needs to authorize it. |
packages/clawdhub/src/http.ts
Outdated
| _httpProxy | ||
| ? new ProxyAgent({ | ||
| uri: _httpProxy, | ||
| requestTls: { timeout: REQUEST_TIMEOUT_MS }, |
There was a problem hiding this comment.
requestTls is for configuring TLS options to the target server. For timeout on ProxyAgent, use connect: { timeout } like the Agent config.
| requestTls: { timeout: REQUEST_TIMEOUT_MS }, | |
| connect: { timeout: REQUEST_TIMEOUT_MS }, |
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/clawdhub/src/http.ts
Line: 25:25
Comment:
`requestTls` is for configuring TLS options to the target server. For timeout on ProxyAgent, use `connect: { timeout }` like the Agent config.
```suggestion
connect: { timeout: REQUEST_TIMEOUT_MS },
```
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e1be9ab00d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
packages/clawdhub/src/http.ts
Outdated
| const _httpProxy = | ||
| process.env.HTTPS_PROXY || | ||
| process.env.HTTP_PROXY || | ||
| process.env.https_proxy || | ||
| process.env.http_proxy |
There was a problem hiding this comment.
Honor NO_PROXY when selecting proxy dispatcher
Installing ProxyAgent whenever any proxy variable is present ignores NO_PROXY/no_proxy, so hosts that should bypass the proxy (for example localhost or internal registries) will still be sent through the proxy and can fail in common corporate setups that export proxy variables globally. This is a behavioral regression introduced by the new global dispatcher path because the previous direct Agent did not force proxying for excluded hosts.
Useful? React with 👍 / 👎.
Address review feedback: - Use undici's EnvHttpProxyAgent instead of ProxyAgent. This properly handles HTTPS_PROXY vs HTTP_PROXY per-scheme, respects NO_PROXY, and uses connect.timeout instead of requestTls. - Update docs to mention NO_PROXY support.
Problem
The ClawHub CLI fails with
fetch failedon any system that requires an HTTP/HTTPS proxy for outbound connections.Root Cause
In
packages/clawdhub/src/http.ts, the CLI creates a customundici.Agentand sets it as the global dispatcher:This overrides any proxy configuration. Node.js's native
fetch()(backed by undici) does not automatically respectHTTP_PROXY/HTTPS_PROXYenvironment variables, and the customAgentexplicitly bypasses any proxy setup.Affected Environments
curlworks but Nodefetch()doesn'tFix
Import
ProxyAgentfromundicialongsideAgent, and use it when a standard proxy environment variable is detected:HTTPS_PROXY/https_proxyHTTP_PROXY/http_proxyNon-breaking: When no proxy env var is set, behavior is identical to before.
Changes
packages/clawdhub/src/http.ts: UseProxyAgentwhen proxy env vars are setdocs/cli.md: Document proxy environment variablesdocs/troubleshooting.md: Add troubleshooting entry forfetch failedbehind proxiesGreptile Summary
Adds HTTP/HTTPS proxy support to ClawHub CLI by using
EnvHttpProxyAgentfrom undici when standard proxy environment variables (HTTP_PROXY,HTTPS_PROXY,http_proxy,https_proxy) are detected. When no proxy variables are set, behavior remains unchanged with direct connections via the regularAgent.packages/clawdhub/src/http.ts: Conditionally usesEnvHttpProxyAgentwhen proxy env vars are set, falling back toAgentotherwiseConfidence Score: 5/5
Last reviewed commit: dc2b902