Skip to content

Commit

Permalink
lib: test_runner#mock:timers respeced timeout_max behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
badkeyy committed Oct 13, 2024
1 parent 5a3da7b commit b098287
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/internal/test_runner/mock/mock_timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit b098287

Please sign in to comment.