test: let the I/O wait of the yielder test pass a check phase

On a slow machine a 1 ms timer can resume within the same timers phase,
before the check phase that ends the slice, so the yielder rightly
yielded and the test failed in CI.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Nikita Ashikhmin
2026-10-08 01:26:34 +04:00
parent 9e88e02c04
commit 773277fcfb

View File

@@ -110,7 +110,11 @@ describe("EventLoopYielder", () => {
for (let i = 0; i < 5; i++) { for (let i = 0; i < 5; i++) {
expect(yielder.maybeYield()).toBeUndefined(); expect(yielder.maybeYield()).toBeUndefined();
time += 20; time += 20;
// A wait on I/O lets the event loop run its phases. A timer alone can
// resume within the same timers phase on a slow machine, before the
// check phase that ends the slice, so the wait ends in that phase.
await new Promise((resolve) => setTimeout(resolve, 1)); await new Promise((resolve) => setTimeout(resolve, 1));
await new Promise((resolve) => setImmediate(resolve));
} }
}); });
}); });