denoland/deno · error · TypeError
Invalid value for 'proxy.transport' option: ${JSONStringify(
Error message
Invalid value for 'proxy.transport' option: ${JSONStringify(proxy.transport)} What it means
Thrown by Deno.createHttpClient when options.proxy.transport is present but not one of the supported values 'http', 'https', 'socks5', 'tcp', 'unix', or 'vsock'. The switch over transport has no matching case, so the default branch reports the offending value (JSON-stringified) as a TypeError. This is a pure config-validation error raised before any network activity.
Source
Thrown at ext/fetch/22_http_client.js:82
const url = proxy.url;
if (
!StringPrototypeStartsWith(url, "socks5:") &&
!StringPrototypeStartsWith(url, "socks5h:")
) {
throw new TypeError(
`The url passed into 'proxy.url' has an invalid scheme for this transport.`,
);
}
proxy.transport = "http";
break;
}
case "tcp":
case "unix":
case "vsock": {
break;
}
default: {
throw new TypeError(
`Invalid value for 'proxy.transport' option: ${
JSONStringify(proxy.transport)
}`,
);
}
}
} else {
proxy.transport = "http";
}
}
const keyPair = loadTlsKeyPair("Deno.createHttpClient", options);
return new HttpClient(
op_fetch_custom_client(
options,
keyPair,
),
);
}View on GitHub (pinned to 89f33cbef2)
Solutions
- Set transport to one of: 'http', 'https', 'socks5', 'tcp', 'unix', 'vsock' (exact lowercase)
- If you only need a standard HTTP(S) proxy, omit transport entirely — it defaults to 'http'
- Lowercase/validate the value against an allowlist before passing it to createHttpClient
Example fix
// before
const client = Deno.createHttpClient({
proxy: { transport: 'SOCKS5', url: 'socks5://127.0.0.1:1080' },
});
// after
const client = Deno.createHttpClient({
proxy: { transport: 'socks5', url: 'socks5://127.0.0.1:1080' },
}); Defensive patterns
Strategy: type-guard
Validate before calling
const TRANSPORTS = new Set(['http', 'https', 'socks5', 'tcp', 'unix', 'vsock']);
function normalizeTransport(p) {
if (p.transport == null) return { ...p, transport: 'http' };
const t = String(p.transport).toLowerCase();
if (!TRANSPORTS.has(t)) {
throw new Error(`invalid proxy.transport '${p.transport}'; expected one of ${[...TRANSPORTS].join(', ')}`);
}
return { ...p, transport: t };
} Type guard
/** @param {unknown} t */
function isValidTransport(t) {
return typeof t === 'string' &&
['http', 'https', 'socks5', 'tcp', 'unix', 'vsock'].includes(t);
} Prevention
- Validate transport against a literal allowlist before createHttpClient
- Lowercase config-sourced values and reject unknown ones loudly at startup
- Remember transport is optional — default 'http' — so omit rather than guess
When it happens
Trigger: Deno.createHttpClient({ proxy: { transport: 'SOCKS5', url: 'socks5://...' } }) — wrong casing, typos like 'sock', values like 'http2', or non-string values (e.g. 5) all land in the default branch.
Common situations: Case-mismatched values from env vars or YAML configs, outdated docs/older Deno versions where fewer transports existed, or programmatically computed transport strings with a typo.
Related errors
- The url passed into 'proxy.url' has an invalid scheme for th
- Cannot create cron job, a unique name is required: received
- Cannot create cron job, a schedule is required: received 'un
- ERR_PROXY_INVALID_CONFIG
- ERR_INVALID_ARG_TYPE
AI-assisted analysis of denoland/deno@89f33cbef2 (2026-08-16).
Data as JSON: /api/errors/e64e1813b9d526f5.
Report an issue: GitHub.