JuliusBrussee/caveman · error · TypeError
unsupported proxy protocol
Error message
unsupported proxy protocol: ${proxy.protocol} What it means
proxyRequest only supports HTTP and HTTPS proxy URLs; it returns the matching request factory for the proxy's scheme. If the proxy URL uses any other protocol (socks5:, ftp:, file:, etc.), it throws a TypeError. The library deliberately supports only http/https CONNECT-style proxies.
Solutions
- Change the proxy URL to use http:// or https:// (e.g. http://proxy.corp:8080) in the env var or config
- If only a SOCKS proxy is available, run a local HTTP-to-SOCKS bridge (e.g. via tools like privoxy, gost, or pp) and point the env var at it
- Print the proxy URL being used and verify its protocol: new URL(process.env.HTTPS_PROXY ?? '').protocol === 'http:' || 'https:'
Example fix
// before HTTPS_PROXY=socks5://127.0.0.1:1080 myapp stats // after HTTPS_PROXY=http://127.0.0.1:1080 myapp stats
Defensive patterns
Strategy: validation
Validate before calling
function assertHttpProxyUrl(raw) {
const u = new URL(raw);
if (u.protocol !== "http:" && u.protocol !== "https:") {
throw new TypeError(`proxy must be http/https, got ${u.protocol}`);
}
return u;
} Type guard
const isHttpLikeProxy = (u: URL): u is URL => u.protocol === "http:" || u.protocol === "https:";
Prevention
- Never set socks5:// in HTTP(S)_PROXY / ALL_PROXY env vars for this tool
- Add a startup check that validates proxy URLs' protocols before making requests
- Document the expected proxy scheme in team onboarding/config templates
When it happens
Trigger: Setting HTTPS_PROXY/HTTP_PROXY/ALL_PROXY (or a proxy config) to a URL whose protocol is not http: or https: — most commonly socks5:// or socks5h:// proxy URLs, or a proxy URL missing the scheme so it parses with an unexpected protocol.
Common situations: Developers pointing the CLI at a corporate SOCKS proxy; copying a proxy URL from tooling that accepts socks5; a proxy env var set without 'http://' prefix producing a parsed protocol they didn't expect.
Related errors
- AbortError
- cave response was not valid JSON
- caveman trial proxy did not become ready on
- provider has no configured upstream URL
- provider upstream URL must be absolute
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/f22154613afa2c9d.
Report an issue: GitHub.
Appendix: source
Thrown at packages/cli/src/proxy-fetch.ts:120
: ["http_proxy", "HTTP_PROXY", "all_proxy", "ALL_PROXY"];
const configured = readEnv(env, names);
return configured ? parseProxyUrl(configured) : null;
}
function proxyAuthHeader(proxy: URL): OutgoingHttpHeaders {
if (!proxy.username && !proxy.password) return {};
const credentials = `${decodeURIComponent(proxy.username)}:${decodeURIComponent(proxy.password)}`;
return { "proxy-authorization": `Basic ${Buffer.from(credentials).toString("base64")}` };
}
function abortError(): Error {
return new DOMException("This operation was aborted", "AbortError") as unknown as Error;
}
function proxyRequest(proxy: URL): typeof httpsRequest {
if (proxy.protocol === "http:") return httpRequest;
if (proxy.protocol === "https:") return httpsRequest;
throw new TypeError(`unsupported proxy protocol: ${proxy.protocol}`);
}
/**
* Opens a CONNECT tunnel so TLS is negotiated with the target, not the proxy.
*
* Terminating TLS at the proxy would hand it the request and, for a signed
* release download, the bytes we are about to trust.
*/
function openTunnel(target: URL, proxy: URL, signal: AbortSignal | null): Promise<Socket> {
return new Promise((resolve, reject) => {
if (signal?.aborted) {
reject(abortError());
return;
}
let settled = false;
const finish = (error?: Error, socket?: Socket) => {
if (settled) {View on GitHub (pinned to 3ee70a1026)