summaryrefslogtreecommitdiff
path: root/cli/js/40_testing.js
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2023-05-22 14:09:31 +0200
committerGitHub <noreply@github.com>2023-05-22 14:09:31 +0200
commitffd3ed9b8ad34471a0ba30727b7321f86c0a30b5 (patch)
tree00b1abc7a673102b61bd2ebf4dec30839eb167fb /cli/js/40_testing.js
parent40bda07ff5751cbb2665a2d134f64826fe3790a8 (diff)
fix(ext/web): improve timers resolution for 0ms timeouts (#19212)
This commit changes the implementation of `ext/web` timers, by using "op_void_async_deferred" for timeouts of 0ms. 0ms timeout is meant to be run at the end of the event loop tick and currently Tokio timers that we use to back timeouts have at least 1ms resolution. That means that 0ms timeout actually take >1ms. This commit changes that and runs 0ms timeout at the end of the event loop tick. One consequence is that "unrefing" a 0ms timer will actually keep the event loop alive (which I believe actually makes sense, the test we had only worked because the timeout took more than 1ms). Ref https://github.com/denoland/deno/issues/19034
Diffstat (limited to 'cli/js/40_testing.js')
-rw-r--r--cli/js/40_testing.js2
1 files changed, 1 insertions, 1 deletions
diff --git a/cli/js/40_testing.js b/cli/js/40_testing.js
index e269b9c9f..ec83ce370 100644
--- a/cli/js/40_testing.js
+++ b/cli/js/40_testing.js
@@ -50,7 +50,7 @@ function opSanitizerDelay() {
return new Promise((resolve) => {
setTimeout(() => {
ArrayPrototypePush(opSanitizerDelayResolveQueue, resolve);
- }, 0);
+ }, 1);
});
}