From 85690cf2f409bc9b17f0801c2fae8a7b860a9712 Mon Sep 17 00:00:00 2001 From: Chris Tate Date: Fri, 16 Oct 2026 21:36:39 -0500 Subject: [PATCH] Order only timers in the promisified timers test 5628-promisify-timers.ts compared a 1 ms timer with an immediate armed at the same time. Their order depends on how much time has passed when the loop reaches its timers phase: once the delay has elapsed, the timer fires before the check phase. Node prints either order under load. The test now orders three timers armed together (1, 10 and 30 ms), which settle in deadline order. The node-types fixture does the same with two timers. --- tests/corpus/5628-promisify-timers.ts | 8 ++++++-- tests/fixtures/node-types/promisify-timers.ts | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/corpus/5628-promisify-timers.ts b/tests/corpus/5628-promisify-timers.ts index 904ffc593..fd53f3814 100644 --- a/tests/corpus/5628-promisify-timers.ts +++ b/tests/corpus/5628-promisify-timers.ts @@ -20,11 +20,15 @@ async function main(): Promise { console.log("module timeout:", await sleepFromModule(1, 42)); console.log("module immediate:", await immediateFromModule(true)); + // Timers armed together settle in deadline order however late the loop + // reaches its timers phase. (An immediate against a short timer is not + // ordered: the timer fires first once its delay has passed when the loop + // reaches the timers phase, in Node too.) const order: string[] = []; const slow = sleep(30, "slow").then((v) => order.push(v)); const fast = sleep(1, "fast").then((v) => order.push(v)); - const now = immediate("now").then((v) => order.push(v)); - await Promise.all([slow, fast, now]); + const middle = sleep(10, "middle").then((v) => order.push(v)); + await Promise.all([slow, fast, middle]); console.log("order:", order.join(",")); const started = Date.now(); diff --git a/tests/fixtures/node-types/promisify-timers.ts b/tests/fixtures/node-types/promisify-timers.ts index 04ff14fd0..da2a8cfea 100644 --- a/tests/fixtures/node-types/promisify-timers.ts +++ b/tests/fixtures/node-types/promisify-timers.ts @@ -11,6 +11,6 @@ console.log(await sleepFromModule(1, true)); const order: string[] = []; await Promise.all([ sleep(20, "slow").then((v) => order.push(v)), - immediate("now").then((v) => order.push(v)), + sleep(1, "fast").then((v) => order.push(v)), ]); console.log(order.join(","));