TooTallNate / proxy-agents

Node.js HTTP Proxy Agents Monorepo
https://proxy-agents.n8.io
872 stars 229 forks source link

Feature Request: Allow `getProxyForUrl` to be asynchronous #264

Closed mook-as closed 4 months ago

mook-as commented 7 months ago

(This request is for proxy-agent)

Currently, GetProxyForUrlCallback returns a string synchronously:

https://github.com/TooTallNate/proxy-agents/blob/dd3b98f0f0bf1da83a58c3330415805568b297f6/packages/proxy-agent/src/index.ts#L25

However, it may be necessary to resolve it asynchronously; for example Electron.Session.resolveProxy(url) returns a Promise<string>.

Since that is only used in async connect(), making that asynchronous shouldn't be too onerous; for backwards compatibility, it should be possible to:

Please let me know if that seems reasonable and I can attempt to whip up a PR. (If you think that it would be easier to implement the feature directly, that's excellent too.)

Thanks!

TooTallNate commented 4 months ago

Sounds reasonable. I'd accept a PR.