Bug Description
My proxy setup is not working with undici, but it succeeds with node-fetch + https-proxy-agent and it also succeeds with plain curl.
Reproducible By
Here is the reproduction repo: https://github.com/nugmanoff/undici-proxy-reproduction/tree/main
In the given repo, if you run node node-fetch.js it will fail with 407, which is expected, because I have emptied the strings in credentials.js (I can give some credentials in DM if someone from the maintainers would be willing to test with real credentials, so that request succeeds with 200).
But if you run node undici.js it will fail with [AbortError]: Proxy response (400) !== 200 when HTTP Tunneling
Even if you run it like curl -x https://:@us.smartproxy.com:10001 -L https://ip.smartproxy.com (notice the empty username and password combo) it will fail with curl: (56) CONNECT tunnel failed, response 407 which matches with node-fetch behavior
Expected Behavior
Expected behavior is that proxy setup works with undici given that it works in node-fetch and curl.
In my understanding receiving 407 on request via proxy with empty credentials is expected behavior here, because it signifies that the request is actually made through proxy. But with undici it gives 400, which is really strange and to me looks like request is not being sent properly in the first place (?).
Maybe I am missing out on some 'standard' which node-fetch and curl doesn't comply with, but undici does – so it fails (deliberately) where others don't. But anyway it is not expected given that it is pretty basic setup. (Btw it also works with axios)
Logs & Screenshots
Full undici failed log
/Users/nugmanoff/Desktop/undici-proxy/node_modules/undici/index.js:115
Error.captureStackTrace(err, this)
^
TypeError: fetch failed
at fetch (/Users/nugmanoff/Desktop/undici-proxy/node_modules/undici/index.js:115:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async file:///Users/nugmanoff/Desktop/undici-proxy/undici.js:12:20 {
cause: DOMException [Error]: Request was cancelled.
at new DOMException (node:internal/per_context/domexception:53:5)
at makeAppropriateNetworkError (/Users/nugmanoff/Desktop/undici-proxy/node_modules/undici/lib/fetch/response.js:448:38)
at httpNetworkFetch (/Users/nugmanoff/Desktop/undici-proxy/node_modules/undici/lib/fetch/index.js:1907:14)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async httpNetworkOrCacheFetch (/Users/nugmanoff/Desktop/undici-proxy/node_modules/undici/lib/fetch/index.js:1594:29)
at async httpFetch (/Users/nugmanoff/Desktop/undici-proxy/node_modules/undici/lib/fetch/index.js:1168:33)
at async /Users/nugmanoff/Desktop/undici-proxy/node_modules/undici/lib/fetch/index.js:601:16
at async mainFetch (/Users/nugmanoff/Desktop/undici-proxy/node_modules/undici/lib/fetch/index.js:585:16) {
cause: RequestAbortedError [AbortError]: Proxy response (400) !== 200 when HTTP Tunneling
Environment
Node v18.18.0
Undici v6.2.1
Node-fetch v3.3.2
Https-proxy-agent v7.0.2
Bug Description
My proxy setup is not working with
undici, but it succeeds withnode-fetch+https-proxy-agentand it also succeeds with plaincurl.Reproducible By
Here is the reproduction repo: https://github.com/nugmanoff/undici-proxy-reproduction/tree/main
In the given repo, if you run
node node-fetch.jsit will fail with 407, which is expected, because I have emptied the strings incredentials.js(I can give some credentials in DM if someone from the maintainers would be willing to test with real credentials, so that request succeeds with 200).But if you run
node undici.jsit will fail with[AbortError]: Proxy response (400) !== 200 when HTTP TunnelingEven if you run it like
curl -x https://:@us.smartproxy.com:10001 -L https://ip.smartproxy.com(notice the empty username and password combo) it will fail withcurl: (56) CONNECT tunnel failed, response 407which matches withnode-fetchbehaviorExpected Behavior
Expected behavior is that proxy setup works with
undicigiven that it works innode-fetchandcurl.In my understanding receiving 407 on request via proxy with empty credentials is expected behavior here, because it signifies that the request is actually made through proxy. But with
undiciit gives 400, which is really strange and to me looks like request is not being sent properly in the first place (?).Maybe I am missing out on some 'standard' which
node-fetchandcurldoesn't comply with, butundicidoes – so it fails (deliberately) where others don't. But anyway it is not expected given that it is pretty basic setup. (Btw it also works withaxios)Logs & Screenshots
Full undici failed log
Environment
Node v18.18.0
Undici v6.2.1
Node-fetch v3.3.2
Https-proxy-agent v7.0.2