oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
73.48k stars 2.71k forks source link

Using fetch with proxy fails with ssl error #12751

Closed Gorthog closed 1 month ago

Gorthog commented 2 months ago

What version of Bun is running?

1.1.20+ae1948925

What platform is your computer?

Linux 6.6.36.3-microsoft-standard-WSL2 x86_64 x86_64

What steps can reproduce the bug?

Use bun fetch like this:

await fetch(url, {
      proxy: `https://${proxy.user}:${proxy.password}@${proxy.url}:${proxy.port}`,
      headers
    });

What is the expected behavior?

same as with node-fetch if i pass in the following format:

const proxyAgent = new HttpsProxyAgent(`https:https://${proxy.user}:${proxy.password}@${proxy.url}:${proxy.port}`);
await fetch(url, {
      agent: proxyAgent,
      headers,
    });

requests completes successfully.

What do you see instead?

SSL: SSL fetching "https://www.amazon.com/s?k=mx%20master%203s". For more information, pass verbose: true in the second argument to fetch()

Additional information

I'm using an https proxy from bright data for data centers. looks like this:

PROXY_URL=brd.superproxy.io
PROXY_USER=user-zone-datacenter_proxy1
PROXY_PORT=22225
PROXY_PASSWORD=somepass

here is the output using verbose: true:

[fetch] > HTTP/1.1 GET https://www.amazon.com/s?k=mx%20master%203s
[fetch] > accept: text/html,application/xhtml+xml,application/xml;q=0.6,image/avif,image/webp,image/apng,*/*;q=0.6,application/signed-exchange;v=b3;q=0
[fetch] > accept-language: he-IL,he;q=0.5,en-US;q=0,en;q=0.9
[fetch] > user-agent: Mozilla/5.0 (X11; CrOS x86_64 8172.45.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.64 Safari/537.36
[fetch] > viewport-width: 1862
[fetch] > Connection: keep-alive
[fetch] > Host: www.amazon.com
[fetch] > Accept-Encoding: gzip, deflate, br

[fetch] < 200 OK
[fetch] < x-luminati-ip: 185.236.94.205
[fetch] < x-luminati-timeline: z21613-init:0,auth:11,dns_resolve_skip:0,ipc_find:96,ext_conn:1,zlum_ztun_conn:0,ztun_conn:212
[fetch] < x-brd-ip: 185.236.94.205
[fetch] < x-brd-timeline: z21613-init:0,auth:11,dns_resolve_skip:0,ipc_find:96,ext_conn:1,zlum_ztun_conn:0,ztun_conn:212
AmitAkuka commented 2 months ago

Having the same issue.