siyuan-note/siyuan · error

SOCKS5 proxy does not support context dialing

Error message

SOCKS5 proxy does not support context dialing

What it means

dialProxyTunnel needs a ContextDialer so the SOCKS5 dial can honor the request context (cancellation/timeouts). If the golang.org/x/net/proxy SOCKS5 dialer it produced does not implement proxy.ContextDialer, this error is thrown. It is an internal capability assertion, normally impossible with the standard x/net library.

Source

Thrown at kernel/util/httprequest.go:202

func dialProxyTunnel(ctx context.Context, proxyURL *url.URL, targetAddr string) (net.Conn, *bufio.Reader, error) {
	proxyAddr, err := proxyAddress(proxyURL)
	if err != nil {
		return nil, nil, err
	}
	dialer := &net.Dialer{Timeout: 30 * time.Second, KeepAlive: 30 * time.Second}
	if strings.EqualFold(proxyURL.Scheme, "socks5") || strings.EqualFold(proxyURL.Scheme, "socks5h") {
		var auth *golangProxy.Auth
		if proxyURL.User != nil {
			password, _ := proxyURL.User.Password()
			auth = &golangProxy.Auth{User: proxyURL.User.Username(), Password: password}
		}
		socksDialer, err := golangProxy.SOCKS5("tcp", proxyAddr, auth, dialer)
		if err != nil {
			return nil, nil, err
		}
		contextDialer, ok := socksDialer.(golangProxy.ContextDialer)
		if !ok {
			return nil, nil, errors.New("SOCKS5 proxy does not support context dialing")
		}
		conn, err := contextDialer.DialContext(ctx, "tcp", targetAddr)
		if err != nil {
			return nil, nil, err
		}
		return conn, bufio.NewReader(conn), nil
	}

	conn, err := dialer.DialContext(ctx, "tcp", proxyAddr)
	if err != nil {
		return nil, nil, err
	}
	if strings.EqualFold(proxyURL.Scheme, "https") {
		tlsConn := tls.Client(conn, &tls.Config{ServerName: proxyURL.Hostname(), NextProtos: []string{"http/1.1"}})
		if err = tlsConn.HandshakeContext(ctx); err != nil {
			conn.Close()
			return nil, nil, err
		}

View on GitHub (pinned to 8641553a1f)

Solutions

  1. Confirm the dependency is the official golang.org/x/net at a current version (go.mod not replacing/forking golang.org/x/net/proxy)
  2. Run `go mod tidy` and remove any temporary `replace` directives affecting x/net
  3. Update golang.org/x/net to the latest patch release and rebuild
  4. If still failing, file a bug with the x/net version from go.sum

Example fix

// before
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 // very old
// after
go get golang.org/x/net@latest
Defensive patterns

Strategy: try-catch

Try / catch

conn, _, err := dialProxyTunnel(ctx, proxyURL, targetAddr)
if err != nil {
    if strings.Contains(err.Error(), "SOCKS5 proxy does not support context dialing") {
        // dependency problem: check go.mod for x/net replaces/forks and rebuild
    }
    return err
}

Prevention

When it happens

Trigger: SOCKS5 proxy configured and golangProxy.SOCKS5 returns a dialer whose concrete type lost the ContextDialer interface — practically only when the dependency version/implementation changed or a custom proxy package is substituted.

Common situations: Pinned or replaced golang.org/x/net / golang.org/x/net/proxy versions in go.mod; vendored forks with modified SOCKS5 implementation; build tags producing a different dialer type.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11). Data as JSON: /api/errors/3ed661c8b44ef2d1. Report an issue: GitHub.