diff options
author | 2023-07-05 03:46:10 -0700 | |
---|---|---|
committer | 2023-07-05 03:46:10 -0700 | |
commit | 3aaec120e7ac26b3904895d2783a08352b63201a (patch) | |
tree | 7cc846f9ed6f12fcf4384d6794591a9506d01a76 /test/js/web/timers/setTimeout-unref-fixture.js | |
parent | c864976da6140c1c92dae8472b1813a1eca8a78c (diff) | |
download | bun-3aaec120e7ac26b3904895d2783a08352b63201a.tar.gz bun-3aaec120e7ac26b3904895d2783a08352b63201a.tar.zst bun-3aaec120e7ac26b3904895d2783a08352b63201a.zip |
Fixes #3512 (#3526)
* Fixes #3512
* Fix `clearTimeout` and `clearInterval` not cancelling jobs same-tick
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Diffstat (limited to 'test/js/web/timers/setTimeout-unref-fixture.js')
-rw-r--r-- | test/js/web/timers/setTimeout-unref-fixture.js | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/js/web/timers/setTimeout-unref-fixture.js b/test/js/web/timers/setTimeout-unref-fixture.js new file mode 100644 index 000000000..97a0f78a2 --- /dev/null +++ b/test/js/web/timers/setTimeout-unref-fixture.js @@ -0,0 +1,12 @@ +const timer = setTimeout(() => {}, 999_999_999); +if (timer.unref() !== timer) throw new Error("Expected timer.unref() === timer"); + +var ranCount = 0; +const going2Refresh = setTimeout(() => { + if (ranCount < 1) going2Refresh.refresh(); + ranCount++; + + if (ranCount === 2) { + console.log("SUCCESS"); + } +}, 1); |