Skip to content

webfetch Transport error on github.com/google.com even with HTTPS_PROXY set — possible undici CONNECT + HTTP/2 issue #29171

Closed as not planned

Description

@Tengxianlai

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_PROXY set 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

  1. Set proxy env vars: $env:HTTPS_PROXY = "http://127.0.0.1:7897"
  2. Launch OpenCode Desktop from the same terminal
  3. 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 error
  • google.com/* → Transport error

Key observation

These failing sites share two characteristics:

  1. They are blocked by GFW and must go through proxy (unlike httpbin/baidu which work directly)
  2. 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:

  1. For sites accessible directly (httpbin, baidu): undici falls back to direct connection, works fine.
  2. For sites that need the proxy (github, google): undici establishes a CONNECT tunnel, but the TLS handshake + HTTP/2 negotiation through the tunnel fails — resulting in Transport 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

  1. github-actions commented on Jul 25, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions