Can we restart the work on overridable globalAgent?Β #23281
Description
Is your feature request related to a problem? Please describe.
There has been quite a few discussions here (#15620, #8381, #1490) on whether nodejs core should support environment variable for http proxy, and so far the consensus has been that proxy support in core is a slippery slope. Which I agree.
But we do need a fix for this headache: when a userland module use a http library, they often don't expose agent option, thus blocking users from using available userland proxy module like node-proxy-agent.
Describe the solution you'd like
I personally believe making http(s).globalAgent overridable is the best way forward:
- userland module can provide whatever proxy support they want, be it http/https/socks/pac.
- user can override
http(s).globalAgentand be confident that ALL http library will respect it. - it has been worked on before (http: make
globalAgentofhttpandhttpsoverridableΒ #11249, Modify https.globalAgent doesn't effectΒ #9057), we should follow it through. - after working on node-fetch for 3 years I realize it's simply too much to ask userland module to expose
agentor support environment variable: it's often too niche a requirement (eg. why should an oauth lib exposeagent?), and many strongly believe it to be nodejs core problem.
In short: overridable globalAgent has the lowest impact of all solutions, allow for highest flexibility when it comes to different proxy types, and has userland code ready to take advantage of it.
Describe alternatives you've considered
See linked discussions.
Activity
Trott commentedon Nov 4, 2018
@nodejs/http
bnoordhuis commentedon Dec 4, 2018
@bitinn If you're interested in working on this, you're welcome to. I'll add the good-first-issue label.
bitinn commentedon Dec 8, 2018
@bnoordhuis sorry I didn't get around to do this due to my own schedule, I hope someone with same need could pick this up.
illBeRoy commentedon Dec 21, 2018
Hey :) this issue was labelled as a "good first issue" so I've taken the liberty to attempt and fix it. This is the relevant PR.
lib: support overriding http\s.globalAgent
lib: support overriding http\s.globalAgent
lib: support overriding http\s.globalAgent
gajus commentedon Apr 24, 2019
@illBeRoy Has this been released?
lib: support overriding http\s.globalAgent
illBeRoy commentedon May 1, 2019
I think this was merged to 11 already.
Seems like it's on 10 staging according to 43dd99c :)
gajus commentedon May 1, 2019
I have since released https://github.com/gajus/global-agent.
lib: support overriding http\s.globalAgent
lib: support overriding http\s.globalAgent
lib: support overriding http\s.globalAgent