You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Expose Undici's ProxyAgent and setGlobalDispatcher within Node #43187
As a motivating example: I'd love to automatically support global Fetch in https://www.npmjs.com/package/global-agent (drop-in lib to make all Node HTTP use the system proxy) but even though Node bundles Undici AFAICT this isn't possible without adding a full separate Undici dep to that lib, which would more than double its size, just [EDIT: largely] to ship code that's already present in Node itself.
This would be immediately solved if ProxyAgent and setGlobalDispatcher were exposed explicitly somewhere in future.
I've just done a quick test on main in Undici: exposing ProxyAgent & setGlobalDispatcher explicitly increases the Undici bundle size from 334.2kb to 336.0kb (+1.8kb / +0.5%).
Could these APIs be included and exposed in future? Agents for HTTP are a very core API that it would be useful to have usable out of the box, the equivalent functionality is usable OOTB for the legacy http module APIs, and 2kb is not a significant jump in bundle size for this functionality.
Replying to the last comment from @mcollina in the previous issue:
I would recommend opening up a separate issue about this topic and bringing it to the TSC. I don't think the whole of Undici has the stability guarantees needed to be part of the Node.js LTS cycle yet.
This makes sense! I'm not aware of Undici's process around stability guarantees like this, but I can understand how there are constraints there.
I do understand this isn't a top top priority since installing & importing Undici elsewhere is a usable workaround, so there's certainly no rush just would justify shipping an unstable API unnecessarily. I do think that the current situation isn't a good end state though, and there are good options we can aim for to fix this, so it would be great to find agreement to aim in that direction in the medium term.
I'm not sure how to take anything to the TSC, but very happy to be included on any discussion of this any time.
That's does work as a workaround, but it's not especially nice as the official API for this, and I think ProxyAgent needs to be available too to make this usable for global Fetch.
In the TSC meeeting of today, we decided that we are going to support HTTP_PROXY, HTTPS_PROXY and NO_PROXY env variables directly in Undici: nodejs/undici#1650.
Reacted by Moshe Atlow, Niko, Niek van der Maas, Kai Sellgren, Steven, silverwind, Théo LUDWIG, Daniel Bankhead, EVA (Entity Value Attribute), Wu Wenbin and 1 more
Reacted by Tim Perry, David Kowis, Travis Fischer, Niko, Kai Sellgren, James Masters, aksjer, Steven, silverwind and Daniel Bankhead
This issue has been marked as stale due to 210 days of inactivity.
It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.
@tmccombs I see. I just searched for the implementation of fetch dispatcher and found that the dispatcher was captured instantly on calling fetch, so in theory there's a hacky way to make proxy happen per fetch without adding a new dependency:
This issue has been marked as stale due to 90 days of inactivity.
It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.
Activity
targos commentedon May 23, 2022
setGlobalDispatcheris exposed:pimterry commentedon May 23, 2022
Replying to the last comment from @mcollina in the previous issue:
This makes sense! I'm not aware of Undici's process around stability guarantees like this, but I can understand how there are constraints there.
I do understand this isn't a top top priority since installing & importing Undici elsewhere is a usable workaround, so there's certainly no rush just would justify shipping an unstable API unnecessarily. I do think that the current situation isn't a good end state though, and there are good options we can aim for to fix this, so it would be great to find agreement to aim in that direction in the medium term.
I'm not sure how to take anything to the TSC, but very happy to be included on any discussion of this any time.
pimterry commentedon May 23, 2022
That's does work as a workaround, but it's not especially nice as the official API for this, and I think ProxyAgent needs to be available too to make this usable for global Fetch.
mcollina commentedon May 23, 2022
I don't think we should expose
undicifurther until we want to considerfetchas stable.frank-dspeed commentedon May 24, 2022
mcollina commentedon May 24, 2022
sosoba commentedon Dec 5, 2022
2022-11-14, Version 19.1.0
mcollina commentedon Dec 5, 2022
That does not mark it stable, on purpose. It's the first step on that journey. This is something we might want to consider right now.
mcollina commentedon Jan 18, 2023
In the TSC meeeting of today, we decided that we are going to support HTTP_PROXY, HTTPS_PROXY and NO_PROXY env variables directly in Undici: nodejs/undici#1650.
GabenGar commentedon Jan 18, 2023
How is it going to handle different casing rules?
feat: support https_proxy
feat: support https_proxy (#1)
JasonKleban commentedon Nov 15, 2023
Is there a workaround to obtain
ProxyAgent?48 remaining items
Bring in undici to support proxied fetch
metcoder95 commentedon Oct 31, 2025
@mcollina is exposing some undici internals still in the plan? Couldn't find the tracking issue from the last collab summit
tmccombs commentedon Nov 19, 2025
Is there currently any workaround to set proxy settings for specific requests that doesn't involve adding a dependency on undici?
github-actions commentedon Jun 25, 2026
This issue has been marked as stale due to 210 days of inactivity.
It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.
hyrious commentedon Jun 25, 2026
Would
http.setGlobalProxyFromEnv([env])solve this issue?tmccombs commentedon Jun 25, 2026
@hyrious that doesn't solve my use case, because I need to use a proxy for some requests, but not all of them, so I can't set proxy settings globally.
hyrious commentedon Jun 25, 2026
@tmccombs I see. I just searched for the implementation of fetch dispatcher and found that the dispatcher was captured instantly on calling fetch, so in theory there's a hacky way to make proxy happen per fetch without adding a new dependency:
This is bound to the implementation so not that stable.
thw0rted commentedon Jun 29, 2026
github-actions commentedon Sep 28, 2026
This issue has been marked as stale due to 90 days of inactivity.
It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.
mbrevda commentedon Sep 28, 2026
nostale