ProxyAgent can not work with Pool request
Bug Description
const pool = new Pool(url);
const proxyAgent = new ProxyAgent("http://one-proxy:8080");
const { statusCode, body } = await pool.request({
...
dispatcher: proxyAgent,
...
...});
when Pool is used, it's not picking up { ..., dispatcher: new ProxyAgent("...")}, nor setGlobalDispatcher(proxyAgent).
However, request is used, ProxyAgent works.
my code is behind the proxy. also Pool is the one I will need to use.
Reproducible By
Expected Behavior
Logs & Screenshots
{
error: Error: getaddrinfo ENOTFOUND eth-testnet-communities-152b99c6597fb22e.elb.us-west-2.amazonaws.com
at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:71:26)
at GetAddrInfoReqWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
errno: -3008,
code: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: 'eth-testnet-communities-152b99c6597fb22e.elb.us-west-2.amazonaws.com'
}
}
Environment
Node v16.14.0
Additional context
This is expected but we likely are not throwing a descriptive error.
Should we throw an error if dispatcher is passed somewhere where it is not expected?
I think so.
why is this expected? so pool is not suppose to use proxy?
Pool is a group of connections to a single client. A proxy (by its definition) allows to connect to all hosts. You should just use the proxy directly.
thanks! any example of using proxy directly?
Isn't https://github.com/nodejs/undici/blob/main/examples/proxy-agent.js enough? I think you can also call proxyAgent.request().
Hardhat plugin uses undici with Pool and has the same problem. It does not work behind corporate proxy.