Closed L3au closed 1 year ago
This code in this repository has been moved to the proxy-agents
monorepo, so I am closing this pull request. If you feel that this issue still exists as of the latest release, feel free to open a new issue over there.
Problem
With Node.js version > v10.16.0, code as below will throw error if set
http.globalAgent
.RunKit Demo
Still occur if using other request library, e.g. axios, got
Environments
Details
After Node v10.16.0, through
http.globalAgent = agent
will overwrite the default http agent and can affect all http requests. Consequently, there is assertion to check agent protocol and request protocol, and will throwERR_INVALID_PROTOCOL
if not match.node/lib/_http_client.js#L106-L121
To handle this, the simplest way is to set
protocol
property to agent instance, just like the internalhttp.Agent
does.Does it make sense to solve the problem? If do, I can create a PR to deal with it.