Skip to content

Commit

Permalink
timers: improve warning message for negative number
Browse files Browse the repository at this point in the history
Partially addressed nodejs#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 e788632
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 e788632

Please sign in to comment.