bun
bun copied to clipboard
`Response(Bun.file())` is slower than `Response(await Bun.file().text())`
What version of Bun is running?
1.1.9-canary.1+4df387d59
What platform is your computer?
Linux 5.15.133.1-microsoft-standard-WSL2 x86_64 x86_64
What steps can reproduce the bug?
Bun.serve({
port: 8080,
async fetch(req: Request) {
const file = Bun.file("test.css");
// slower
return new Response(file);
// faster
return new Response(await file.text(), {
headers: {
"content-length": file.size.toString(),
"content-type": file.type,
},
});
},
});
What is the expected behavior?
I would expect Bun.file() to be faster than using await Bun.file().text().
(Top test is Bun.file(), bottom is Bun.file().text())
What do you see instead?
It can be as much as 3ms faster, which is a pretty big difference.