Repository navigation
Conversation
ProxyAgent only special-cased socks5: and socks:, so any other scheme (e.g. socks5h:, socks4:) fell through to the HTTP proxy path and failed in parseOrigin with "the URL must start with `http:` or `https:`". That message is misleading because SOCKS proxies are supported, and it does not name the rejected scheme. Validate the proxy protocol up front and report the rejected and the supported protocols. EnvHttpProxyAgent inherits the improved error. Closes nodejs#6082.
This was referenced Oct 23, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This relates to...
Closes #6082
Rationale
ProxyAgentonly special-casessocks5:andsocks:. Any other scheme falls through to the HTTP proxy path, whereclientFactory(url)->new Client(url)->parseOriginthrows:That message is wrong for proxy URIs (SOCKS is supported) and does not name the rejected scheme. The common trigger is
socks5h://inHTTP_PROXY/HTTPS_PROXY, which makesEnvHttpProxyAgentthrow at construction.Changes
Features
N/A
Bug Fixes
ProxyAgentvalidates the proxy protocol before building any dispatcher and throwsInvalidArgumentError: Unsupported proxy protocol 'socks5h:'. Supported protocols: http:, https:, socks5:, socks:.EnvHttpProxyAgentinherits this.test/issue-6082.js(string,URL, and{ uri }inputs;clientFactoryis not called; supported schemes still accepted, including uppercase input normalized by WHATWG URL;EnvHttpProxyAgentwithhttpProxy/httpsProxy).uriindocs/docs/api/ProxyAgent.md.Breaking Changes and Deprecations
Unsupported schemes already threw at construction with the default
clientFactory, so default usage only gets a better message. The one behavior change: a customclientFactory(plus a customfactoryfor plain-HTTP forwarding) could previously accept an arbitrary scheme, since tunneling goes through that client. Such URIs are now rejected. I don't know of real usage of this, but flagging it in case maintainers prefer to validate only when the default factories are in use.Status