(Not a) Bug in Inject node?

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.

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

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?

[{"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"]]}]

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

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.

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

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.

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?

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

1 Like

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

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

Thank you both :grinning:

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