Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@std/async/unstable_wait_for.ts has flaky test #6384

Open
BlackAsLight opened this issue Feb 5, 2025 · 1 comment
Open

@std/async/unstable_wait_for.ts has flaky test #6384

BlackAsLight opened this issue Feb 5, 2025 · 1 comment

Comments

@BlackAsLight
Copy link
Contributor

https://github.com/denoland/std/actions/runs/13148004852/job/36690141694

ERRORS 

waitFor() throws DOMException on timeout => ./async/unstable_wait_for_test.ts:16:6
error: AssertionError: Expected actual: "112" to be close to "100": delta "12" is greater than "10".
  throw new AssertionError(
        ^
    at assertAlmostEquals (file:///Users/runner/work/std/std/assert/almost_equals.ts:51:9)
    at file:///Users/runner/work/std/std/async/unstable_wait_for_test.ts:25:3

 FAILURES 

waitFor() throws DOMException on timeout => ./async/unstable_wait_for_test.ts:16:6

FAILED | 3099 passed (2720 steps) | 1 failed | 11 ignored (1m9s)

error: Test failed
Error: Process completed with exit code 1.

Deno.test("waitFor() throws DOMException on timeout", async () => {
let flag = false;
const id = setTimeout(() => flag = true, 1000);
const start = Date.now();
const error = await assertRejects(
() => waitFor(() => flag === true, 100),
DOMException,
"Signal timed out.",
);
assertAlmostEquals(Date.now() - start, 100, 10);
assertEquals(error.name, "TimeoutError");
clearTimeout(id);
});

@kt3k
Copy link
Member

kt3k commented Feb 6, 2025

Maybe let's use FakeTime to simulate the timers. That should remove flakiness caused by timer's timings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants