Skip to content

Commit

Permalink
timer: improve warning message for negative number
Browse files Browse the repository at this point in the history
Partially addressed #46596 to keep the consistency of the warning message for TIMEOUT_MAX number as the negative number will be set to 1.
  • Loading branch information
jakecastelli committed Feb 16, 2023
1 parent 1b87cb6 commit 0f7f6f1
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/internal/timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ class Timeout {
' a 32-bit signed integer.' +
'\nTimeout duration was set to 1.',
'TimeoutOverflowWarning');
} else if (after < 0) {
process.emitWarning(`${after} is a negative number.` +
'\nTimeout duration was set to 1.');
}
after = 1; // Schedule on next tick, follows browser behavior
}
Expand Down

0 comments on commit 0f7f6f1

Please sign in to comment.