Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

fix(proxy): map socks5h rules onto Chromium's SOCKS5 scheme

vastsa88207665abd2
diff --git a/packages/shared/src/network-proxy.test.ts b/packages/shared/src/network-proxy.test.ts
index 655d306e9..aeb6bb3db 100644
--- a/packages/shared/src/network-proxy.test.ts
+++ b/packages/shared/src/network-proxy.test.ts
@@ -102,6 +102,27 @@ describe("chromium and env projections", () => {
});
});
+ it("maps curl's socks5h rule onto a Chromium-supported SOCKS5 rule", () => {
+ // Chromium has no `socks5h` proxy scheme: session.setProxy accepts the
+ // rule and then resolves every URL to no proxy, so requests fail with
+ // net::ERR_NO_SUPPORTED_PROXIES instead of using the user's proxy (#419).
+ expect(
+ chromiumProxyConfig({
+ mode: "custom",
+ url: "socks5h://user:[email protected]:1080",
+ }),
+ ).toEqual({
+ proxyRules: "socks5://user:[email protected]:1080",
+ proxyBypassRules: DEFAULT_NETWORK_PROXY_BYPASS,
+ });
+ expect(
+ chromiumProxyConfig({ mode: "custom", url: "socks://127.0.0.1:1080" }),
+ ).toEqual({
+ proxyRules: "socks://127.0.0.1:1080",
+ proxyBypassRules: DEFAULT_NETWORK_PROXY_BYPASS,
+ });
+ });
+
it("omits Chromium <local> from NO_PROXY and does not set HTTP_PROXY for SOCKS", () => {
const socks = proxyEnvAssignments({
mode: "custom",
diff --git a/packages/shared/src/network-proxy.ts b/packages/shared/src/network-proxy.ts
index a61314190..385a7f6fd 100644
--- a/packages/shared/src/network-proxy.ts
+++ b/packages/shared/src/network-proxy.ts
@@ -214,11 +214,26 @@ export function chromiumProxyConfig(
const parsed = parseProxyUrl(settings.url ?? "");
if (!parsed.ok) return { mode: "direct" };
return {
- proxyRules: parsed.value.href,
+ proxyRules: chromiumProxyRules(parsed.value),
proxyBypassRules: effectiveProxyBypass(settings),
};
}
+/**
+ * Chromium proxy rule for one parsed proxy URL.
+ *
+ * Chromium understands `http`, `https`, `socks` (SOCKS5), `socks4` and
+ * `socks5` proxy rules, but not curl's `socks5h` spelling: `session.setProxy`
+ * accepts the unsupported rule set without an error, then resolves to no
+ * proxy at all and every request fails with `net::ERR_NO_SUPPORTED_PROXIES`.
+ * Chromium's SOCKS5 already hands the hostname to the proxy, so `socks5h`
+ * maps onto `socks5` without changing where names are resolved.
+ */
+export function chromiumProxyRules(proxy: ParsedProxyUrl): string {
+ if (proxy.scheme !== "socks5h") return proxy.href;
+ return formatProxyHref({ ...proxy, scheme: "socks5" });
+}
+
/** Bypass list suitable for `NO_PROXY` / curl `--noproxy` (no Chromium `<local>`). */
export function envProxyBypass(settings: NetworkProxySettings): string {
return effectiveProxyBypass(settings)