diff --git a/lib/internal/test_runner/mock/mock_timers.js b/lib/internal/test_runner/mock/mock_timers.js index a1e0043cafcf29..1f4852e21e9aec 100644 --- a/lib/internal/test_runner/mock/mock_timers.js +++ b/lib/internal/test_runner/mock/mock_timers.js @@ -48,6 +48,8 @@ let kResistStopPropagation; let kMock; // Initial epoch to which #now should be set to const kInitialEpoch = 0; +/** @see lib/internal/timers.js#TIMEOUT_MAX */ +const TIMEOUT_MAX = 2 ** 31 - 1; function compareTimersLists(a, b) { return (a.runAt - b.runAt) || (a.id - b.id); @@ -288,6 +290,10 @@ class MockTimers { } #createTimer(isInterval, callback, delay, ...args) { + if (delay > TIMEOUT_MAX) { + delay = 1; + } + const timerId = this.#currentTimer++; const opts = { __proto__: null,