{"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/8641553a1f07374001902d3ce773285db1292b2d/kernel/util/httprequest.go#L184-L220","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Confirm the dependency is the official golang.org/x/net at a current version (go.mod not replacing/forking golang.org/x/net/proxy)","Run `go mod tidy` and remove any temporary `replace` directives affecting x/net","Update golang.org/x/net to the latest patch release and rebuild","If still failing, file a bug with the x/net version from go.sum"],"exampleFix":"// before\ngolang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 // very old\n// after\ngo get golang.org/x/net@latest","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"conn, _, err := dialProxyTunnel(ctx, proxyURL, targetAddr)\nif err != nil {\n    if strings.Contains(err.Error(), \"SOCKS5 proxy does not support context dialing\") {\n        // dependency problem: check go.mod for x/net replaces/forks and rebuild\n    }\n    return err\n}","preventionTips":["Pin official current golang.org/x/net; avoid forks of golang.org/x/net/proxy","Run go mod tidy and review go.sum after dependency changes","Rebuild after Go/x/net upgrades to catch interface drift early"],"tags":["proxy","socks5","network"],"backgroundTag":"internal-invariant-violation","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}