{"record":{"id":"3ed661c8b44ef2d1","repo":"siyuan-note/siyuan","slug":"socks5-proxy-does-not-support-context-dialing","errorCode":null,"errorMessage":"SOCKS5 proxy does not support context dialing","messagePattern":"SOCKS5 proxy does not support context dialing","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/util/httprequest.go","lineNumber":202,"sourceCode":"func dialProxyTunnel(ctx context.Context, proxyURL *url.URL, targetAddr string) (net.Conn, *bufio.Reader, error) {\n\tproxyAddr, err := proxyAddress(proxyURL)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\tdialer := &net.Dialer{Timeout: 30 * time.Second, KeepAlive: 30 * time.Second}\n\tif strings.EqualFold(proxyURL.Scheme, \"socks5\") || strings.EqualFold(proxyURL.Scheme, \"socks5h\") {\n\t\tvar auth *golangProxy.Auth\n\t\tif proxyURL.User != nil {\n\t\t\tpassword, _ := proxyURL.User.Password()\n\t\t\tauth = &golangProxy.Auth{User: proxyURL.User.Username(), Password: password}\n\t\t}\n\t\tsocksDialer, err := golangProxy.SOCKS5(\"tcp\", proxyAddr, auth, dialer)\n\t\tif err != nil {\n\t\t\treturn nil, nil, err\n\t\t}\n\t\tcontextDialer, ok := socksDialer.(golangProxy.ContextDialer)\n\t\tif !ok {\n\t\t\treturn nil, nil, errors.New(\"SOCKS5 proxy does not support context dialing\")\n\t\t}\n\t\tconn, err := contextDialer.DialContext(ctx, \"tcp\", targetAddr)\n\t\tif err != nil {\n\t\t\treturn nil, nil, err\n\t\t}\n\t\treturn conn, bufio.NewReader(conn), nil\n\t}\n\n\tconn, err := dialer.DialContext(ctx, \"tcp\", proxyAddr)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\tif strings.EqualFold(proxyURL.Scheme, \"https\") {\n\t\ttlsConn := tls.Client(conn, &tls.Config{ServerName: proxyURL.Hostname(), NextProtos: []string{\"http/1.1\"}})\n\t\tif err = tlsConn.HandshakeContext(ctx); err != nil {\n\t\t\tconn.Close()\n\t\t\treturn nil, nil, err\n\t\t}","sourceCodeStart":184,"sourceCodeEnd":220,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/util/httprequest.go#L184-L220","documentation":"When a SOCKS5 proxy is configured, the transport builds a golang.org/x/net/proxy SOCKS5 dialer and asserts it also implements ContextDialer so the request context (timeouts, cancellation) can be honored. If the returned dialer does not, the tunnel cannot be created safely and fails with this error. In practice this only occurs if golangProxy.SOCKS5 returns a non-standard implementation.","triggerScenarios":"HTTP_PROXY/HTTPS_PROXY (or configured proxy URL) with a socks5/socks5h scheme, where the dialer produced by golangProxy.SOCKS5 fails the ContextDialer type assertion during the agent HTTP request.","commonSituations":"Pinned/older version of golang.org/x/net where the SOCKS5 dialer did not implement DialContext; vendored or replaced proxy package; tests stubbing proxy.FromURL with a plain dialer.","solutions":["Update golang.org/x/net to a current version (SOCKS5 dialer implements ContextDialer in all recent releases)","Check go.mod for a replace/pin of golang.org/x/net and remove or bump it","Switch the proxy to an HTTP CONNECT proxy if upgrading is not possible","Run go mod tidy and rebuild to ensure the vendored copy is current"],"exampleFix":"// before: pinned old version in go.mod\n// golang.org/x/net v0.0.0-2019...\n// after\ngo get golang.org/x/net@latest && go mod tidy","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"if d, ok := socksDialer.(golangProxy.ContextDialer); !ok {\n    return errors.New(\"SOCKS5 dialer lacks DialContext; upgrade golang.org/x/net\")\n}","tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"SOCKS5 proxy does not support context dialing\") {\n    return fmt.Errorf(\"proxy stack too old; upgrade golang.org/x/net or use an HTTP CONNECT proxy\")\n}","preventionTips":["Keep golang.org/x/net current; avoid replaces/pins on it","Prefer HTTP CONNECT proxies if you control the proxy infrastructure","Run go mod tidy after dependency upgrades"],"tags":["socks5","proxy","dependency","context"],"backgroundTag":"operation-not-supported","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}