From 0f7f6f16f0bd3c9d2b2563b07c89967a2b394499 Mon Sep 17 00:00:00 2001 From: jakecastelli <959672929@qq.com> Date: Thu, 16 Feb 2023 11:59:33 +1030 Subject: [PATCH] timer: improve warning message for negative number Partially addressed #46596 to keep the consistency of the warning message for TIMEOUT_MAX number as the negative number will be set to 1. --- lib/internal/timers.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/internal/timers.js b/lib/internal/timers.js index dac5938eabd7df..94ef2c0cc7d02a 100644 --- a/lib/internal/timers.js +++ b/lib/internal/timers.js @@ -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 }