Skip to content

timers: Fail early when callback is not a function

setTimeout() and setInterval() currently throw errors when receiving non-function objects as their first argument, but only do so when trying to execute the callback, i.e. after the waited time has passed. This may complicate debugging when a lot of calls to setTimeout()/setInterval() from different places are involved, so failing as early as possible seems like a good idea.

Strangely, setTimeout() currently silently ignores an falsy first argument, while setInterval() does not. This patch leaves this behaviour unchanged since existing applications may rely on it.

Merge request reports

Loading