oven-sh / bun

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

Bun.serve -> request.header memory leak #9261

Open shpaw415 opened 8 months ago

shpaw415 commented 8 months ago

What version of Bun is running?

1.0.30+1424a196f

What platform is your computer?

Linux 6.5.0-21-generic x86_64 x86_64

What steps can reproduce the bug?

when serving http.server request passed to a module function

What is the expected behavior?

the request must return header from the current request

What do you see instead?

sometime break the header data by replacing it with an old broken request header. Entries of the header are chunking start and end. Exemple: (send -> "Accept: SomeHeader") (received -> "ept: SomeHe") from previous request

Additional information

the problem do not occure on every request, but when the bug rise the nexts requests are buging as well. call of request.headers.toJSON in the root of the fetch function in Bun.serve. Seam to solve the problem

Electroid commented 8 months ago

Do you mind sharing some code so we can reproduce this? Just to make sure we're getting your report right.

shpaw415 commented 8 months ago

( https://github.com/shpaw415/bunext ) .bunext/react-ssr/server.ts here you can find inline comments showing where bug begin

Jarred-Sumner commented 8 months ago

Can you simplify the reproduction into a single file we can run?

shpaw415 commented 8 months ago

Perfect I'ill do a POC

github-actions[bot] commented 3 months ago

This issue is stale and may be closed due to inactivity. If you're still running into this, please leave a comment.