mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-14 12:55:16 +08:00
setTimeout and setInterval set a delay outside [1, 2^31-1] to 1ms, as before, and now also emit the warning Node's Timeout constructor emits then: TimeoutOverflowWarning for each delay past 2^31-1, and TimeoutNegativeWarning and TimeoutNaNWarning once per process. The warnings reach the 'warning' listeners and the default stderr report on the next tick, as process.emitWarning delivers them. An omitted or undefined delay warns nothing, and neither do the global functions while mock.timers mocks them; node:timers imports keep warning. The check is the runtime's scr_timer_user_delay, which a call emits only when its delay is not a literal in range. An untyped delay (a JavaScript value) now converts with ToNumber, as Node's `after *= 1` does, instead of failing a number check: null, booleans, strings, arrays and objects become delays, and undefined stays the omitted delay.