# Can the Delay node rate limit, but pass first message immediately, and always pass on the latest message?

**URL:** https://discourse.nodered.org/t/can-the-delay-node-rate-limit-but-pass-first-message-immediately-and-always-pass-on-the-latest-message/67170
**Category:** General
**Created:** [31 August 2022 08:34 UTC](https://discourse.nodered.org/t/can-the-delay-node-rate-limit-but-pass-first-message-immediately-and-always-pass-on-the-latest-message/67170 "2022-08-31T08:34:55Z")
**Posts on this page:** 1
**Showing post:** 62

<div class="post-metadata">

### Author: ![drmibell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/drmibell/32/8424_2.png) [@drmibell](https://discourse.nodered.org/u/drmibell)
#### Post date: [4 September 2022 21:28 UTC](https://discourse.nodered.org/t/can-the-delay-node-rate-limit-but-pass-first-message-immediately-and-always-pass-on-the-latest-message/67170/62 "2022-09-04T21:28:23Z")

</div>

As author of the `q-gate` node, I want to help out here, but I have been too busy to follow the discussion in any depth. Based on the original post, I think this flow meets the requirements without the possibility of race conditions. (See this [discussion](https://discourse.nodered.org/t/close-gate-after-one-message-has-passed-through/56575/7) and [this one](https://discourse.nodered.org/t/timing-question-avoiding-race-conditions/55616).)

 ![Untitled](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/d/fdf420fbdb64b10d4db8fc94d0553d6be80a82c2.jpeg)

```auto
[{"id":"67659f7786234008","type":"inject","z":"0ae9d1938fe1cb0d","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"2","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":130,"y":80,"wires":[["e8de0d8f5c30616b","92b84dfdf699239e"]]},{"id":"e8de0d8f5c30616b","type":"function","z":"0ae9d1938fe1cb0d","name":"queue after","func":"return [[msg,{payload:'queue',topic:'control'}]]","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":390,"y":80,"wires":[["c453ff7e92e4428d"]]},{"id":"92b84dfdf699239e","type":"trigger","z":"0ae9d1938fe1cb0d","name":"open after 5s","op1":"","op2":"open","op1type":"nul","op2type":"str","duration":"5","extend":false,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":310,"y":120,"wires":[["1354ec7ffed7352c"]]},{"id":"c453ff7e92e4428d","type":"q-gate","z":"0ae9d1938fe1cb0d","name":"","controlTopic":"control","defaultState":"open","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","queueCmd":"queue","defaultCmd":"default","triggerCmd":"trigger","flushCmd":"flush","resetCmd":"reset","peekCmd":"peek","dropCmd":"drop","statusCmd":"status","maxQueueLength":"1","keepNewest":true,"qToggle":false,"persist":false,"storeName":"memory","x":650,"y":80,"wires":[["1248d518fe22581f"]]},{"id":"1354ec7ffed7352c","type":"change","z":"0ae9d1938fe1cb0d","name":"topic:control","rules":[{"t":"set","p":"topic","pt":"msg","to":"control","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":470,"y":120,"wires":[["c453ff7e92e4428d"]]},{"id":"1248d518fe22581f","type":"debug","z":"0ae9d1938fe1cb0d","name":"debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":770,"y":80,"wires":[]}]

```

I could easily be mistaken, so if anyone can demonstrate a race condition here, either in theory or practice, please let me know.

---

_[View the full topic](https://discourse.nodered.org/t/can-the-delay-node-rate-limit-but-pass-first-message-immediately-and-always-pass-on-the-latest-message/67170)._
