mirror of
https://github.com/oven-sh/bun
synced 2026-02-11 11:29:02 +00:00
### What does this PR do? On Linux, AbortSignal.timeout created a file descriptor for each timeout and did not keep the event loop alive when a timer was active. This is fixed. ### How did you verify your code works? Fewer flaky tests --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Claude <claude@anthropic.ai>
29 lines
659 B
TypeScript
29 lines
659 B
TypeScript
using server2 = Bun.serve({
|
|
port: 0,
|
|
async fetch() {
|
|
await Bun.sleep(1000);
|
|
return new Response("test");
|
|
},
|
|
});
|
|
|
|
using server = Bun.serve({
|
|
port: 0,
|
|
error(error) {
|
|
return new Response(error.message, { status: 500 });
|
|
},
|
|
async fetch() {
|
|
const signal = AbortSignal.timeout(1);
|
|
return await fetch(server2.url.href, { signal });
|
|
},
|
|
});
|
|
|
|
let url = server.url.href;
|
|
|
|
const responses: Response[] = [];
|
|
for (let i = 0; i < 10; i++) {
|
|
responses.push(await fetch(url));
|
|
}
|
|
// we fail if any of the requests succeeded
|
|
const anySuccess = responses.some(res => res.status >= 200 && res.status < 500);
|
|
process.exit(anySuccess ? 1 : 0);
|