mirror of
https://github.com/oven-sh/bun
synced 2026-02-19 07:12:24 +00:00
21 lines
474 B
TypeScript
21 lines
474 B
TypeScript
import { expect, test } from "bun:test";
|
|
|
|
// numeric timeout option should abort fetch when exceeded
|
|
|
|
test("fetch timeout option aborts request", async () => {
|
|
try {
|
|
using server = Bun.serve({
|
|
port: 0,
|
|
async fetch() {
|
|
await Bun.sleep(100);
|
|
return new Response("unreachable");
|
|
},
|
|
});
|
|
|
|
await fetch(server.url, { timeout: 10 });
|
|
expect.unreachable();
|
|
} catch (err: any) {
|
|
expect(err.name).toBe("TimeoutError");
|
|
}
|
|
});
|