oven-sh / bun

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

Sveltekit (using vite) returns cloudflare 520 status #6687

Open Paultje52 opened 10 months ago

Paultje52 commented 10 months ago

What version of Bun is running?

1.0.5, 1.0.6,1.0.7, 1.0.8 and 1.0.9

After building, the issue persists in 1.0.10, 1.0.11, 1.0.12, 1.0.13, 1.0.14, 1.0.15, 1.0.16, 1.0.17 and 1.0.18.

What platform is your computer?

Linux 5.4.0-156-generic x86_64 x86_64

What steps can reproduce the bug?

What is the expected behavior?

The page should load without any errors, just like in 1.0.4 and lower

What do you see instead?

Error 520: Web server is returning an unknown error Error code 520 (see screenshot) image

Additional information

It seems "random" what pages give an error. Sometimes the page does work and sometimes it doesn't. Open the dev tools, head to network and see what requests fail with 520.

There aren't any errors reported in the terminal. Using it without cloudflare and nginx works without any problems, but because it doesn't happen in bun 1.0.4 and earlier, it isn't a misconfiguration or an nginx or cloudflare issue.

I'm sorry that I don't have more direct errors, it's a really vague error. The only way to "resolve" it is by staying on bun 1.0.4 or lower or don't use nginx/cloudflare with ssl.

Electroid commented 10 months ago

Can you confirm that this does not happen in Node.js?

Paultje52 commented 10 months ago

Yes, the same issue doesn't happen in node

Paultje52 commented 9 months ago

The issue is resolved for development (bun --bun run dev) in v1.0.10, but it's still present when building the code

Paultje52 commented 8 months ago

When updating nginx to 1.24, the problem seems to be resolved. Still strange why the problem doesn't appear in node or versions of bun before 1.0.5. It also only happens when nginx accepts a http/2 request. Here is the error log (from nginx) of a request that returned 520.

2024/01/08 20:16:58 [warn] 3421326#3421326: *10 upstream sent more data than specified in "Content-Length" header while reading upstream, client: <MY_IP>, server: <MY_DOMAIN>, request: "GET /icon/favicon-dark.ico HTTP/2.0", upstream: "http://127.0.0.1:3001/icon/favicon-dark.ico", host: "<MY_DOMAIN>", referrer: "https://<MY_DOMAIN>/dash/exams"