Skip to content
Merged
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
8 changes: 6 additions & 2 deletions tests/corpus/5628-promisify-timers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@ async function main(): Promise<void> {
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();
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/node-types/promisify-timers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(","));
Loading