summaryrefslogtreecommitdiff
path: root/ext/node/polyfills
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2023-05-23 00:19:44 +0200
committerGitHub <noreply@github.com>2023-05-22 22:19:44 +0000
commit25232fa4e8ba2e9601699cff0cc9a6e6f03171ee (patch)
treec4cfedd12283b73319437e9aaccbbf8dd4c66796 /ext/node/polyfills
parent7b4c483aa159794cdb9d57d3252c2980fba45469 (diff)
fix(node): make sure "setImmediate" is not clamped to 4ms (#19213)
This commit changes implementation of "setImmediate" from "node:timers" module to 0ms timer that is never clamped to 4ms no matter how many nested calls there are. Closes https://github.com/denoland/deno/issues/19034
Diffstat (limited to 'ext/node/polyfills')
-rw-r--r--ext/node/polyfills/timers.ts7
1 files changed, 5 insertions, 2 deletions
diff --git a/ext/node/polyfills/timers.ts b/ext/node/polyfills/timers.ts
index 9c688f242..e5e64529c 100644
--- a/ext/node/polyfills/timers.ts
+++ b/ext/node/polyfills/timers.ts
@@ -8,6 +8,7 @@ import * as timers from "ext:deno_web/02_timers.js";
const clearTimeout_ = timers.clearTimeout;
const clearInterval_ = timers.clearInterval;
+const setTimeoutUnclamped = timers.setTimeoutUnclamped;
export function setTimeout(
callback: (...args: unknown[]) => void,
@@ -46,10 +47,12 @@ export function clearInterval(timeout?: Timeout | number | string) {
}
// TODO(bartlomieju): implement the 'NodeJS.Immediate' versions of the timers.
// https://github.com/DefinitelyTyped/DefinitelyTyped/blob/1163ead296d84e7a3c80d71e7c81ecbd1a130e9a/types/node/v12/globals.d.ts#L1120-L1131
-export const setImmediate = (
+export function setImmediate(
cb: (...args: unknown[]) => void,
...args: unknown[]
-): Timeout => setTimeout(cb, 0, ...args);
+): Timeout {
+ return setTimeoutUnclamped(cb, 0, ...args);
+}
export const clearImmediate = clearTimeout;
export default {