From 8f854782b13658f169920a1a7a21b8e6b64a0c00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Thu, 10 Aug 2023 06:01:35 +0200 Subject: fix(ext/timers): some timers are not resolved (#20055) Fixes https://github.com/denoland/deno/issues/19866 --- cli/tests/unit/timers_test.ts | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'cli/tests') diff --git a/cli/tests/unit/timers_test.ts b/cli/tests/unit/timers_test.ts index c50cb779c..5c076ad09 100644 --- a/cli/tests/unit/timers_test.ts +++ b/cli/tests/unit/timers_test.ts @@ -727,3 +727,32 @@ Deno.test({ assertEquals(output, ""); }, }); + +// Regression test for https://github.com/denoland/deno/issues/19866 +Deno.test({ + name: "regression for #19866", + fn: async () => { + const timeoutsFired = []; + + // deno-lint-ignore require-await + async function start(n: number) { + let i = 0; + const intervalId = setInterval(() => { + i++; + if (i > 2) { + clearInterval(intervalId!); + } + timeoutsFired.push(n); + }, 20); + } + + for (let n = 0; n < 100; n++) { + start(n); + } + + // 3s should be plenty of time for all the intervals to fire + // but it might still be flaky on CI. + await new Promise((resolve) => setTimeout(resolve, 3000)); + assertEquals(timeoutsFired.length, 300); + }, +}); -- cgit v1.2.3