Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions libs/core/02_timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,8 @@
} else {
after *= 1;
}
if (!(after >= 1 && after <= TIMEOUT_MAX)) {
after = 1;
if (after < 1 || !(after <= TIMEOUT_MAX)) {
after = after > TIMEOUT_MAX ? TIMEOUT_MAX : 1;
}

const id = nextTimerId++;
Expand Down
14 changes: 14 additions & 0 deletions tests/unit/timers_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,20 @@ Deno.test({
},
});

Deno.test({
name: "AbortSignal.timeout() with large delay does not abort instantly",
fn: async () => {
const signal = AbortSignal.timeout(2 ** 53 - 1);
let aborted = false;
signal.onabort = () => {
aborted = true;
};
// Wait 500ms — the signal should NOT have aborted
await new Promise((resolve) => setTimeout(resolve, 500));
assertEquals(aborted, false);
},
});

Deno.test(async function setTimeoutWithStringCallback() {
const global = globalThis as unknown as {
timeoutStringTest: number;
Expand Down
Loading