Repository navigation
Description
title: "webfetch Transport error on github.com/google.com even with HTTPS_PROXY set"
labels: ["bug", "windows", "proxy"]
assignees: []
Description
webfetch returns Transport error for certain HTTPS sites (github.com/, google.com/) even when HTTPS_PROXY environment variable is correctly set. The same proxy works perfectly with curl.exe -x.
This is related to #27892 but focuses on a different layer: not about proxy configuration (which is solved by env vars), but about undici's proxy CONNECT tunnel implementation failing for specific sites.
Environment
- OS: Windows 10/11
- App: OpenCode Desktop (GUI, launched via terminal with
$env:HTTPS_PROXYset or via script) - Proxy: Clash Verge (HTTP proxy at 127.0.0.1:7897)
- Network: Behind GFW (China mainland), sites like github.com/google.com are unreachable without proxy
$env:HTTPS_PROXY=http://127.0.0.1:7897$env:HTTP_PROXY=http://127.0.0.1:7897$env:NO_PROXY=localhost,127.0.0.1,::1,.local
Steps to Reproduce
- Set proxy env vars:
$env:HTTPS_PROXY = "http://127.0.0.1:7897" - Launch OpenCode Desktop from the same terminal
- Ask agent to webfetch the following URLs
Results
| URL | webfetch | curl.exe -x 127.0.0.1:7897 |
|---|---|---|
https://httpbin.org/get |
✅ OK | ✅ 200 |
https://www.baidu.com |
✅ OK | ✅ 200 |
https://api.github.com |
✅ OK | ✅ 200 |
https://api.github.com/repos/torvalds/linux |
✅ OK | ✅ 200 |
https://github.com/torvalds/linux |
❌ Transport error | ✅ 200 |
https://github.com/nicepkg/opencode |
❌ Transport error | ✅ 200 |
https://github.com/OpenListTeam/OpenList |
❌ Transport error | ✅ 200 |
https://www.google.com |
❌ Transport error | ✅ 302 |
https://www.google.com/search?q=test |
❌ Transport error | ✅ 302 |
https://www.google.com.hk/search?q=test |
❌ Transport error | ✅ 302 |
Analysis
What works
httpbin.org,baidu.com→ these are directly accessible from China without proxy. The fact they work proves the HTTP client is functional.api.github.com/*→ returns JSON, works fine through proxy.
What fails
github.com/*(HTML pages) → Transport errorgoogle.com/*→ Transport error
Key observation
These failing sites share two characteristics:
- They are blocked by GFW and must go through proxy (unlike httpbin/baidu which work directly)
- They use HTTP/2
Root cause hypothesis
webfetch uses the effect library's FetchHttpClient, which wraps Node.js global fetch API (backed by undici in Node.js, or Chromium's net.fetch in Electron).
On the Desktop version (Electron), when webfetch makes an HTTPS request through a CONNECT proxy:
- For sites accessible directly (httpbin, baidu):
undicifalls back to direct connection, works fine. - For sites that need the proxy (github, google):
undiciestablishes a CONNECT tunnel, but the TLS handshake + HTTP/2 negotiation through the tunnel fails — resulting inTransport error.
curl.exe -x uses libcurl's different TLS/HTTP stack and handles the same CONNECT tunnel correctly.
This suggests a compatibility issue in undici's proxy CONNECT implementation when dealing with:
- HTTP/2 connections through CONNECT tunnels, OR
- Large HTTP response headers (GitHub's CSP header is ~5KB), OR
- Specific TLS cipher suite negotiation through the proxy
Expected behavior
webfetch should handle HTTPS CONNECT proxy correctly for ALL sites, matching the behavior of curl.exe -x.
Workaround
Use curl.exe -x in bash as a fallback for fetching sites that fail with webfetch:
curl.exe -x http://127.0.0.1:7897 -s "https://github.com/{owner}/{repo}"
Activity
github-actions commentedon Jul 25, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.