diff options
author | await-ovo <13152410380@163.com> | 2023-07-03 03:11:34 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-02 19:11:34 +0000 |
commit | 0f4051a37ad23377091043206e64126003caa480 (patch) | |
tree | 3fbe98a9c78ee716665dcadaa962ea132eb9bfea /cli/tests | |
parent | 01f0d03ae82c422c1f9551f3bfbb57daac769ddc (diff) |
fix(ext/node): ignore cancelled timer when node timer refresh (#19637)
For timers that have already executed clearTimeout, there is no need to recreate a new timer when refresh is executed again.
Diffstat (limited to 'cli/tests')
-rw-r--r-- | cli/tests/unit_node/timers_test.ts | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/cli/tests/unit_node/timers_test.ts b/cli/tests/unit_node/timers_test.ts index 8676edb76..d110b44e4 100644 --- a/cli/tests/unit_node/timers_test.ts +++ b/cli/tests/unit_node/timers_test.ts @@ -1,6 +1,6 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -import { assert } from "../../../test_util/std/testing/asserts.ts"; +import { assert, fail } from "../../../test_util/std/testing/asserts.ts"; import * as timers from "node:timers"; import * as timersPromises from "node:timers/promises"; @@ -50,3 +50,13 @@ Deno.test("[node/timers/promises setTimeout]", () => { assert(p instanceof Promise); return p; }); + +// Regression test for https://github.com/denoland/deno/issues/17981 +Deno.test("[node/timers refresh cancelled timer]", () => { + const { setTimeout, clearTimeout } = timers; + const p = setTimeout(() => { + fail(); + }, 1); + clearTimeout(p); + p.refresh(); +}); |