# Minimum time for setTimeout. It looks like it cant be less than 30ms

**URL:** <https://discourse.nodered.org/t/minimum-time-for-settimeout-it-looks-like-it-cant-be-less-than-30ms/100414>\
**Category:** Developing Nodes\
**Created:** [19 February 2026 16:22 UTC](https://discourse.nodered.org/t/minimum-time-for-settimeout-it-looks-like-it-cant-be-less-than-30ms/100414 "2026-02-19T16:22:08Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bannsaenger](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bannsaenger/32/55628_2.png) [@Bannsaenger](https://discourse.nodered.org/u/Bannsaenger)\
**Post date:** [19 February 2026 16:22 UTC](https://discourse.nodered.org/t/minimum-time-for-settimeout-it-looks-like-it-cant-be-less-than-30ms/100414/1 "2026-02-19T16:22:08Z")

</div>

I am the developer of the [@bannsaenger/node-red-contrib-artnet-controller](https://flows.nodered.org/node/@bannsaenger/node-red-contrib-artnet-controller).  
This node uses a timer mechanism to handle transitions where values are send in specific timing. Therefor i use the `setTimeout` like:

> this.mainWorker = setTimeout((function() {  
> .. do stuff here  
> }.bind(this)), this.senderClock);

and `this.mainWorker.refresh()` for continuation because the timer has not to run ever.

If `senderClock` is less than 30ms, the mainWorker is called every 30ms. If i set it to 50ms it is called every 60ms.

It seems like the main eventloop runs only every 30ms.

Can this be configured? I cant find a setting in settings.js

Thanks

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [19 February 2026 16:44 UTC](https://discourse.nodered.org/t/minimum-time-for-settimeout-it-looks-like-it-cant-be-less-than-30ms/100414/2 "2026-02-19T16:44:41Z")

</div>

> [@Bannsaenger](#):
>
> Can this be configured? I cant find a setting in settings.js

In short - no.

Node.js timers are not real-time and only guarantee a minimum delay. The callback runs when the event loop is free, so under load (or due to OS timer resolution) you will see jitter and drift. There is no setting in Node-RED or Node.js to configure the event loop frequency.

If you need tighter timing guarantees (e.g. consistent \<30ms intervals), Node.js is not deterministic enough for that use case. For most Node-RED flows, timing should be treated as approximate rather than exact.

Even if you wrote the timing part in a non garbage collected lang (like rust or C) you are still at the mercy of the OS scheduler / Kernel timer resolution / Process scheduling latency / Interrupts / CPU load

If you genuinely need consistent sub-30 ms precision with low jitter, the correct answer is to use a real-time system (e.g. PREEMPT\_RT Linux) or move this code to a microcontroller

* * *

instead of using times, can you not make this event based? e.g. `x` happens, do `y` instead of _polling_ at hight speed?

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [19 February 2026 19:58 UTC](https://discourse.nodered.org/t/minimum-time-for-settimeout-it-looks-like-it-cant-be-less-than-30ms/100414/3 "2026-02-19T19:58:21Z")

</div>

Steve is, of course 😃 , completely correct in his assessment. However, there is one _possible_ thing that might help if you really _must_ use a rapid setTimeout (though I agree fully with Steve, event-driven is by far a better way to go if you can).

That is to create a worker thread. These became stable in node.js in v12. A worker thread has its own instance of the v8 engine and its own loop.

However, as already indicated, if your issue is actually that the underlying hardware is CPU-bound, this probably won't help too much.

---

<div class="post-metadata">

**Author:** ![Bannsaenger](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bannsaenger/32/55628_2.png) [@Bannsaenger](https://discourse.nodered.org/u/Bannsaenger)\
**Post date:** [20 February 2026 09:06 UTC](https://discourse.nodered.org/t/minimum-time-for-settimeout-it-looks-like-it-cant-be-less-than-30ms/100414/4 "2026-02-20T09:06:02Z")

</div>

Ok, thank you so far.

I've done some other projects in Node.js with the use of such timers.

You are right with the jitter and that the timing isn't as precise, but in all my other projects the resolution is not bound to 30ms or something like that.

This must be a restriction in the core of Node-RED.

I take a look at the worker thread.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [20 February 2026 09:22 UTC](https://discourse.nodered.org/t/minimum-time-for-settimeout-it-looks-like-it-cant-be-less-than-30ms/100414/5 "2026-02-20T09:22:45Z")

</div>

> [@Bannsaenger](#):
>
> This must be a restriction in the core of Node-RED.

Node-RED does not (cannot) impose a minimum timer resolution. It uses the standard Node.js timer APIs, and their behaviour is determined by Node.js, libuv and the host OS.

What _can_ happen:

- If the flow is busy (lots of nodes executing, any synchronous work, CPU heavy loads), the event loop may not return to the timers quick enough.
- If a node blocks (e.g. synchronous ops, filesystem ops, tight non-async loops), timers will be delayed.
- If the system is under load, you’ll also see drift.

But thay ^ resulty in _event loop delay_ (not a 30 ms floor).

PS: Using worker threads wont (completely) solve the underlying issue (tho they _might_ improve regularity since they have their own event loop). Workers still use the same OS scheduler / libuv timer implementation / are still non-real-time

---

<div class="post-metadata">

**Author:** ![Bannsaenger](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bannsaenger/32/55628_2.png) [@Bannsaenger](https://discourse.nodered.org/u/Bannsaenger)\
**Post date:** [20 February 2026 13:12 UTC](https://discourse.nodered.org/t/minimum-time-for-settimeout-it-looks-like-it-cant-be-less-than-30ms/100414/6 "2026-02-20T13:12:23Z")

</div>

Steve, I need to apologize to you.

I moved over to linux and the 30ms behavior is gone.

It seems to be a restriction in Node.js on Windows OS.

The jitter and the inaccuracy is acceptable for my use case.

Thanks to all for your help.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [6 March 2026 13:13 UTC](https://discourse.nodered.org/t/minimum-time-for-settimeout-it-looks-like-it-cant-be-less-than-30ms/100414/7 "2026-03-06T13:13:19Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
