mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 19:08:50 +00:00
* Fixes #3512 * Fix `clearTimeout` and `clearInterval` not cancelling jobs same-tick --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
19 lines
565 B
TypeScript
19 lines
565 B
TypeScript
import { describe, test } from "bun:test";
|
|
import { setTimeout, clearTimeout, setInterval, clearInterval, setImmediate } from "node:timers";
|
|
|
|
for (const fn of [setTimeout, setInterval]) {
|
|
describe(fn.name, () => {
|
|
test("unref is possible", done => {
|
|
const timer = fn(() => {
|
|
done(new Error("should not be called"));
|
|
}, 1).unref();
|
|
const other = fn(() => {
|
|
clearInterval(other);
|
|
done();
|
|
}, 2);
|
|
if (fn === setTimeout) clearTimeout(timer);
|
|
if (fn === setInterval) clearInterval(timer);
|
|
});
|
|
});
|
|
}
|