-
Notifications
You must be signed in to change notification settings - Fork 551
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
undici
with ProxyAgent
fails with 400
where curl
and node-fetch
with https-proxy-agent
succeeds
#2542
Comments
cc @RafaelGSS |
A PR that fixes this would be highly welcomed, thanks! |
@mcollina @KhafraDev is it safe to assume that it is a confirmed [by you] bug? I am double-checking so that I am sure that I didn't miss anything in proxy setup and my reproduction is valid. |
At a first look, it seems valid. |
I've been playing with it and it seems the request is badly formatted, the server is replying with I'm pretty unsure what would be failing as we attach to the common Output: Status code: 400 <html><body><h1>400 Bad request</h1>
Your browser sent an invalid request.
</body></html> |
I'm looking to it. |
Found the bug. PR is coming |
Bug Description
My proxy setup is not working with
undici
, but it succeeds withnode-fetch
+https-proxy-agent
and 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.js
it 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.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 withcurl: (56) CONNECT tunnel failed, response 407
which matches withnode-fetch
behaviorExpected Behavior
Expected behavior is that proxy setup works with
undici
given that it works innode-fetch
andcurl
.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
andcurl
doesn't comply with, butundici
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 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
The text was updated successfully, but these errors were encountered: