# Delay when using mytimeout node

**URL:** <https://discourse.nodered.org/t/delay-when-using-mytimeout-node/22498>\
**Category:** Dashboard\
**Created:** [2 March 2020 13:12 UTC](https://discourse.nodered.org/t/delay-when-using-mytimeout-node/22498 "2020-03-02T13:12:25Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![YLM-UJM](https://avatars.discourse-cdn.com/v4/letter/y/9de053/32.png) [@YLM-UJM](https://discourse.nodered.org/u/YLM-UJM)\
**Post date:** [2 March 2020 13:12 UTC](https://discourse.nodered.org/t/delay-when-using-mytimeout-node/22498/1 "2020-03-02T13:12:25Z")

</div>

Hi,

I have tried to make some progress bar using chart bar and mytimeout node. So I have 5 horizontal chart bar which means 5 steps of my program. When the first mytimeout is over, another one begins and so on. So I can have many steps running one after each other. But it looks I have a delay when one mytimeout is over and when the new one begins... Someone has an idea ?

Thank you

```auto
[{"id":"24095369.3ba49c","type":"tab","label":"Flow 11","disabled":false,"info":""},{"id":"7c6c7448.8bde5c","type":"ui_chart","z":"24095369.3ba49c","name":"","group":"448586ea.7f42a8","order":2,"width":6,"height":2,"label":"Fmax Droite N1","chartType":"horizontalBar","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"0","ymax":"3","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#ff3333","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":1320,"y":380,"wires":[[]]},{"id":"ea35b564.b74718","type":"mytimeout","z":"24095369.3ba49c","name":"Fmax Droite N1","outtopic":"","outsafe":"","outwarning":"","outunsafe":"off","warning":"0","timer":"3","debug":false,"ndebug":false,"ignoreCase":false,"repeat":false,"again":false,"x":1020,"y":380,"wires":[["1bcf5fe1.b61d9"],["7c6c7448.8bde5c"]]},{"id":"1926930.9633b6d","type":"mytimeout","z":"24095369.3ba49c","name":"Recup Fmax N1","outtopic":"","outsafe":"","outwarning":"","outunsafe":"off","warning":"0","timer":"3","debug":false,"ndebug":false,"ignoreCase":false,"repeat":false,"again":false,"x":1020,"y":580,"wires":[["7155d527.f2ae6c"],["44553cbc.cbb974"]]},{"id":"1bcf5fe1.b61d9","type":"function","z":"24095369.3ba49c","name":"","func":"if (msg.payload == 'off') {\n msg.payload = 'on'\n}\nreturn msg;","outputs":1,"noerr":0,"x":830,"y":500,"wires":[["1926930.9633b6d"]]},{"id":"44553cbc.cbb974","type":"ui_chart","z":"24095369.3ba49c","name":"","group":"448586ea.7f42a8","order":3,"width":6,"height":2,"label":"Recup Post Fmax N1","chartType":"horizontalBar","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"0","ymax":"3","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":1340,"y":580,"wires":[[]]},{"id":"5bc83a09.4924d4","type":"function","z":"24095369.3ba49c","name":"","func":"msg.payload = 3\nreturn msg;","outputs":1,"noerr":0,"x":550,"y":620,"wires":[["7c6c7448.8bde5c","44553cbc.cbb974","788a24ce.b5d11c","f5cb9d51.25cbb","ffdd6657.7974e8"]]},{"id":"788a24ce.b5d11c","type":"ui_chart","z":"24095369.3ba49c","name":"","group":"448586ea.7f42a8","order":4,"width":6,"height":2,"label":"Fmax Droite N2","chartType":"horizontalBar","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"0","ymax":"3","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#ff3333","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":1320,"y":760,"wires":[[]]},{"id":"73da4ea1.bca96","type":"mytimeout","z":"24095369.3ba49c","name":"Fmax Droite N2","outtopic":"","outsafe":"","outwarning":"","outunsafe":"off","warning":"0","timer":"3","debug":false,"ndebug":false,"ignoreCase":false,"repeat":false,"again":false,"x":1020,"y":760,"wires":[["172c3b1b.69ca85"],["788a24ce.b5d11c"]]},{"id":"4a6a4347.2d280c","type":"mytimeout","z":"24095369.3ba49c","name":"Recup Fmax N2","outtopic":"","outsafe":"","outwarning":"","outunsafe":"off","warning":"0","timer":"3","debug":false,"ndebug":false,"ignoreCase":false,"repeat":false,"again":false,"x":1020,"y":940,"wires":[[],["f5cb9d51.25cbb","abe89208.ceeb1"]]},{"id":"172c3b1b.69ca85","type":"function","z":"24095369.3ba49c","name":"","func":"if (msg.payload == 'off') {\n msg.payload = 'on'\n}\nreturn msg;","outputs":1,"noerr":0,"x":850,"y":860,"wires":[["4a6a4347.2d280c"]]},{"id":"f5cb9d51.25cbb","type":"ui_chart","z":"24095369.3ba49c","name":"","group":"448586ea.7f42a8","order":5,"width":6,"height":2,"label":"Recup Post Fmax N2","chartType":"horizontalBar","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"0","ymax":"3","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":1340,"y":940,"wires":[[]]},{"id":"7155d527.f2ae6c","type":"function","z":"24095369.3ba49c","name":"","func":"if (msg.payload == 'off') {\n msg.payload = 'on'\n}\nreturn msg;","outputs":1,"noerr":0,"x":850,"y":680,"wires":[["73da4ea1.bca96"]]},{"id":"a5347043.afc05","type":"mytimeout","z":"24095369.3ba49c","name":"Préparation","outtopic":"","outsafe":"","outwarning":"","outunsafe":"off","warning":"0","timer":"3","debug":false,"ndebug":false,"ignoreCase":false,"repeat":false,"again":false,"x":1010,"y":180,"wires":[["de9b1309.05b59"],["ffdd6657.7974e8"]]},{"id":"ffdd6657.7974e8","type":"ui_chart","z":"24095369.3ba49c","name":"","group":"448586ea.7f42a8","order":1,"width":6,"height":2,"label":"Préparation","chartType":"horizontalBar","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"0","ymax":"3","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#f2f155","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":1310,"y":180,"wires":[[]]},{"id":"de9b1309.05b59","type":"function","z":"24095369.3ba49c","name":"","func":"if (msg.payload == 'off') {\n msg.payload = 'on'\n}\nreturn msg;","outputs":1,"noerr":0,"x":830,"y":280,"wires":[["ea35b564.b74718"]]},{"id":"2bc8f415.f15abc","type":"ui_button","z":"24095369.3ba49c","name":"","group":"77e8a1e0.4442a","order":5,"width":0,"height":0,"passthru":false,"label":"Quand vous êtes prêts, cliquez ici ","tooltip":"","color":"","bgcolor":"","icon":"","payload":"on","payloadType":"str","topic":"","x":480,"y":120,"wires":[["a5347043.afc05","77091505.3e085c"]]},{"id":"77091505.3e085c","type":"function","z":"24095369.3ba49c","name":"","func":"var now = new Date();\nmsg.payload = now.getTime();\nflow.set('t1', msg.payload);\nreturn msg;","outputs":1,"noerr":0,"x":600,"y":260,"wires":[["99462f8b.767b9"]]},{"id":"99462f8b.767b9","type":"debug","z":"24095369.3ba49c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":580,"y":400,"wires":[]},{"id":"369383b2.8308ec","type":"debug","z":"24095369.3ba49c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1530,"y":240,"wires":[]},{"id":"d58e121.3a232f","type":"inject","z":"24095369.3ba49c","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":350,"y":620,"wires":[["5bc83a09.4924d4"]]},{"id":"abe89208.ceeb1","type":"function","z":"24095369.3ba49c","name":"","func":"if (msg.payload === 0) {\n msg.payload = new Date().getTime();\n flow.set('t2', msg.payload);\n}\nreturn msg;","outputs":1,"noerr":0,"x":1280,"y":240,"wires":[["369383b2.8308ec"]]},{"id":"9420fc40.3e53f","type":"debug","z":"24095369.3ba49c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":950,"y":1060,"wires":[]},{"id":"e4f3f1ac.e9f0b","type":"function","z":"24095369.3ba49c","name":"","func":"msg.payload = flow.get('t2') - flow.get('t1');\nreturn msg;","outputs":1,"noerr":0,"x":770,"y":1060,"wires":[["9420fc40.3e53f"]]},{"id":"e9677333.7f267","type":"inject","z":"24095369.3ba49c","name":"Tstop - Tstart","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":570,"y":1060,"wires":[["e4f3f1ac.e9f0b"]]},{"id":"ba90e488.d01f78","type":"inject","z":"24095369.3ba49c","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":320,"y":180,"wires":[["a5347043.afc05","77091505.3e085c"]]},{"id":"448586ea.7f42a8","type":"ui_group","z":"","name":"Compte à rebours","tab":"f75bbc9f.a03b1","order":3,"disp":true,"width":"6","collapse":false},{"id":"77e8a1e0.4442a","type":"ui_group","z":"","name":"Préparation au test","tab":"f75bbc9f.a03b1","order":2,"disp":true,"width":"6","collapse":false},{"id":"f75bbc9f.a03b1","type":"ui_tab","z":"","name":"Préhension SELFIT","icon":"dashboard","order":4,"disabled":false,"hidden":false}]

```

---

<div class="post-metadata">

**Author:** ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)\
**Post date:** [2 March 2020 15:40 UTC](https://discourse.nodered.org/t/delay-when-using-mytimeout-node/22498/2 "2020-03-02T15:40:10Z")

</div>

The flow you shared has only one node. May you possibly share the whole flow (if it is not confidential or too large) ?

---

<div class="post-metadata">

**Author:** ![YLM-UJM](https://avatars.discourse-cdn.com/v4/letter/y/9de053/32.png) [@YLM-UJM](https://discourse.nodered.org/u/YLM-UJM)\
**Post date:** [2 March 2020 15:47 UTC](https://discourse.nodered.org/t/delay-when-using-mytimeout-node/22498/3 "2020-03-02T15:47:32Z")

</div>

Sorry, my bad. I have updated my code.  
Thank you for your concern.

---

<div class="post-metadata">

**Author:** ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)\
**Post date:** [2 March 2020 16:47 UTC](https://discourse.nodered.org/t/delay-when-using-mytimeout-node/22498/4 "2020-03-02T16:47:32Z")

</div>

It is not possible to import your flow. Could you please edit your post to include the flow between three backticks? 😉

````auto
```
Your code
```

````

---

<div class="post-metadata">

**Author:** ![YLM-UJM](https://avatars.discourse-cdn.com/v4/letter/y/9de053/32.png) [@YLM-UJM](https://discourse.nodered.org/u/YLM-UJM)\
**Post date:** [3 March 2020 08:22 UTC](https://discourse.nodered.org/t/delay-when-using-mytimeout-node/22498/5 "2020-03-03T08:22:08Z")

</div>

Thank you! It's updated.  
I have add into my node a time computation. I compute the time between the start (when I lauch the code) and the time at the end. I have 5 mytimeout node of 3s so, the computed time should be 15 seconds. Or the time is eerytime different and between 16 and 18 seconds most of the time...  
Thank you for you help.

---

<div class="post-metadata">

**Author:** ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)\
**Post date:** [3 March 2020 14:47 UTC](https://discourse.nodered.org/t/delay-when-using-mytimeout-node/22498/6 "2020-03-03T14:47:03Z")

</div>

Good, I confirm that i can also see the issue.

I guess this delay is intrinsic to the mytimeout node.

I suggest you to use the contrib-interval-length to assess how much the mytimeout node delays message. Apparently it is more than you would expect. If you confirm those findings better to contact the developer of the mytimeout node for a deeper assessment.

I did a quick testing with below flow and noted that the node delays the message 3.8 seconds when configured to delay 3 seconds.

![a-01](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/5/75c6d12f5bb445fb527bffae22601987d2c64bc6.png)

![a-02](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/6/c6f3d28f840c385f6f827dcfd6bb972b54ad523a.png)

> **[node-red-contrib-interval-length](https://flows.nodered.org/node/node-red-contrib-interval-length)**
>
> A Node Red node to measure the interval length between successive messages

---

<div class="post-metadata">

**Author:** ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)\
**Post date:** [3 March 2020 15:03 UTC](https://discourse.nodered.org/t/delay-when-using-mytimeout-node/22498/7 "2020-03-03T15:03:12Z")

</div>

Same testing for the standard delay node.

![a-03](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/b/9b12ab0c9b5dc72083f8360fa9931400c9ef3d45.png)

![a-04](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/f/8f5b5f85a1076e2bf0570587a5933baab1fd78c4.png)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [3 March 2020 15:23 UTC](https://discourse.nodered.org/t/delay-when-using-mytimeout-node/22498/8 "2020-03-03T15:23:04Z")

</div>

I imagine it decrements and tests only every second and its internal 1 second tick is not synchronised to the incoming message so it is never going to accurate for measuring short intervals.

---

<div class="post-metadata">

**Author:** ![YLM-UJM](https://avatars.discourse-cdn.com/v4/letter/y/9de053/32.png) [@YLM-UJM](https://discourse.nodered.org/u/YLM-UJM)\
**Post date:** [5 March 2020 09:29 UTC](https://discourse.nodered.org/t/delay-when-using-mytimeout-node/22498/9 "2020-03-05T09:29:49Z")

</div>

thank you for your time, I will do that. I also have tried to use a template node a create a javascript function using setInterval() and it works quiet well.

---

<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:** [4 April 2020 09:29 UTC](https://discourse.nodered.org/t/delay-when-using-mytimeout-node/22498/10 "2020-04-04T09:29:52Z")

</div>

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