# (Not a) Bug in Inject node?

**URL:** <https://discourse.nodered.org/t/not-a-bug-in-inject-node/87625>\
**Category:** Core Development\
**Created:** [1 May 2024 12:12 UTC](https://discourse.nodered.org/t/not-a-bug-in-inject-node/87625 "2024-05-01T12:12:54Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [1 May 2024 12:12 UTC](https://discourse.nodered.org/t/not-a-bug-in-inject-node/87625/1 "2024-05-01T12:12:54Z")

</div>

I see this with Node-red v3.1.9, node.js 18.20.2, also with node.js 20, on a Raspberry Pi Zero Two.  
Inject nodes are set to fire after a range of short delays.  
It appears that they do fire (the delayed message is eventually delivered) but messages triggered less than about 8 seconds after startup don't get passed to a debug node, nor is other downstream processing triggered. (But notice that the delay node is triggered,)

First image: DEPLOY. All of these inject nodes are new, so at deploy, they all fire.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/b/1b9af88c3935da8979b51c911f7aad5863efc2d5.png)

Second image: Reboot Pi and wait for Node-red to start.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/c/cc171b11887f8bfd33aa3a85bb9a99c1640ebb49.png)

Only the Inject after 10 sec shows up, though the 10 sec delay node does get triggered.  
If I restart Node-red rather than rebooting, more debug messages show up, but not the 0.1sec initial delay.

What's going on?

```auto
[{"id":"fdc7b9edf9fb44f9","type":"inject","z":"7f20ad1a9174e987","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":true,"onceDelay":"2","topic":"","payload":"Inject after 2 sec","payloadType":"str","x":450,"y":760,"wires":[["f7d5fe126bb47c28"]]},{"id":"9be553d0d36b0efe","type":"inject","z":"7f20ad1a9174e987","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":true,"onceDelay":"4","topic":"","payload":"Inject after 4 sec","payloadType":"str","x":450,"y":800,"wires":[["f7d5fe126bb47c28"]]},{"id":"12a325d5b82a3106","type":"inject","z":"7f20ad1a9174e987","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":true,"onceDelay":"5","topic":"","payload":"Inject after 5 sec","payloadType":"str","x":450,"y":840,"wires":[["f7d5fe126bb47c28"]]},{"id":"f88bb54c44b1f92d","type":"inject","z":"7f20ad1a9174e987","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":true,"onceDelay":"6","topic":"","payload":"Inject after 6 sec","payloadType":"str","x":450,"y":880,"wires":[["f7d5fe126bb47c28"]]},{"id":"70004a8e73766c05","type":"inject","z":"7f20ad1a9174e987","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":true,"onceDelay":"10","topic":"","payload":"Inject after 10 sec","payloadType":"str","x":450,"y":920,"wires":[["f7d5fe126bb47c28"]]},{"id":"f7d5fe126bb47c28","type":"debug","z":"7f20ad1a9174e987","name":"debug 18","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":700,"y":880,"wires":[]},{"id":"a3c9889370fe5712","type":"inject","z":"7f20ad1a9174e987","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":true,"onceDelay":"0.1","topic":"","payload":"Inject after 0.1 sec","payloadType":"str","x":450,"y":720,"wires":[["31492ac2a39a7fb7","f7d5fe126bb47c28"]]},{"id":"31492ac2a39a7fb7","type":"delay","z":"7f20ad1a9174e987","name":"","pauseType":"delay","timeout":"10","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":700,"y":720,"wires":[["662e0868576770ea"]]},{"id":"662e0868576770ea","type":"change","z":"7f20ad1a9174e987","name":"payload = Delayed 10 sec","rules":[{"t":"set","p":"payload","pt":"msg","to":"Delayed 10 sec","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":780,"wires":[["f7d5fe126bb47c28"]]}]

```

---

<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:** [1 May 2024 12:32 UTC](https://discourse.nodered.org/t/not-a-bug-in-inject-node/87625/2 "2024-05-01T12:32:07Z")

</div>

This may well be that the browser has not yet connected to the server when the inject is happening.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [1 May 2024 12:39 UTC](https://discourse.nodered.org/t/not-a-bug-in-inject-node/87625/3 "2024-05-01T12:39:35Z")

</div>

Yes that makes sense.

I'm not sure if "Inject after 0.1 second" is 0.1 second after Node-red starts up or 0.1 sec after a browser connects to it.

---

<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:** [1 May 2024 12:56 UTC](https://discourse.nodered.org/t/not-a-bug-in-inject-node/87625/4 "2024-05-01T12:56:02Z")

</div>

> [@jbudd](#):
>
> I'm not sure if "Inject after 0.1 second" is 0.1 second after Node-red starts up or 0.1 sec after a browser connects to it.

It is after node-red starts. There may be no browser connected when node-red starts up, or there could be 10 browsers connected.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [1 May 2024 13:04 UTC](https://discourse.nodered.org/t/not-a-bug-in-inject-node/87625/5 "2024-05-01T13:04:23Z")

</div>

You can confirm exactly what is happening by ticking the 'log to system console' option in the Debug node; you'll see all of the expected messages in the node-red console log without the need for an editor to be open and connected.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [1 May 2024 13:32 UTC](https://discourse.nodered.org/t/not-a-bug-in-inject-node/87625/6 "2024-05-01T13:32:23Z")

</div>

> [@knolleary](#):
>
> 'log to system console' option

Ah yes, if only I'd mastered accessing the system log in RPIOS Bookworm!

But it's the activity in the editor that I need to make reliable since I'm trying to reload the page after rebooting the Pi.

I can inject after 10 seconds, just hoping that's a long enough delay.  
Or does Node-red know when the first browser connection occurs?

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [1 May 2024 14:04 UTC](https://discourse.nodered.org/t/not-a-bug-in-inject-node/87625/7 "2024-05-01T14:04:41Z")

</div>

> Or does Node-red know when the first browser connection occurs?

Node-RED does, but that isn't exposed to nodes - flows typically don't care about the editor and whether anything is connected, so it isn't something we cater for

---

<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:** [1 May 2024 19:48 UTC](https://discourse.nodered.org/t/not-a-bug-in-inject-node/87625/8 "2024-05-01T19:48:15Z")

</div>

> [@jbudd](#):
>
> Ah yes, if only I'd mastered accessing the system log in RPIOS

If you start node-red using  
`node-red-start`  
then the log will be displayed for you.

---

<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:** [1 May 2024 20:26 UTC](https://discourse.nodered.org/t/not-a-bug-in-inject-node/87625/9 "2024-05-01T20:26:38Z")

</div>

On Linux, `sudo journalctl -u node-red -f -n 500 -o cat --no-hostname` should show you the log.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [1 May 2024 20:35 UTC](https://discourse.nodered.org/t/not-a-bug-in-inject-node/87625/10 "2024-05-01T20:35:22Z")

</div>

Thank you both 😀

---

<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:** [15 May 2024 20:35 UTC](https://discourse.nodered.org/t/not-a-bug-in-inject-node/87625/11 "2024-05-15T20:35:43Z")

</div>

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