Skip to content

Can we restart the work on overridable globalAgent? #23281

Closed
@bitinn

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:

  1. userland module can provide whatever proxy support they want, be it http/https/socks/pac.
  2. user can override http(s).globalAgent and be confident that ALL http library will respect it.
  3. it has been worked on before (http: make globalAgent of http and https overridable #11249, Modify https.globalAgent doesn't effect #9057), we should follow it through.
  4. after working on node-fetch for 3 years I realize it's simply too much to ask userland module to expose agent or support environment variable: it's often too niche a requirement (eg. why should an oauth lib expose agent?), 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.

Metadata

Assignees

No one assigned

    Labels

    feature requestIssues that request new features to be added to Node.js.good first issueIssues that are suitable for first-time contributors.httpIssues or PRs related to the http subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions