oven-sh / bun

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

Crash with Bun.serve() + TLS + Bun.file() in new Response #13474

Open MrCarbone opened 2 months ago

MrCarbone commented 2 months ago

What version of Bun is running?

1.1.25+fe62a6140

What platform is your computer?

windows10 x64

What steps can reproduce the bug?

import { serve, file, sleep } from "bun";
import { readFileSync } from "node:fs";
serve({
  port: 443,
  key: file("./utility/localhost.key"),
  cert: file("./utility/localhost.crt"),
  async fetch(request, server) {
    await sleep(1000);
    return new Response(file("./index.html")); // ==============> Wrong
    //return new Response(readFileSync("./index.html","utf-8"));  ====> OK
    //return new Response("aaaaa");  === =================> OK
  },
});

What is the expected behavior?

i use sleep() in fetch method , all things above is ok, but response by Bun.file when i send request with browser; bun stops and exit, without show any error.

What do you see instead?

No response

Additional information

No response