Catch node causing Infinite error loop

619 views
Skip to first unread message

Michael Steenkamp

unread,
Apr 22, 2015, 11:20:48 PM4/22/15
to node...@googlegroups.com
If any part of an error handling chain attached to a catch node throws an error, then node-red gets into an infinite error loop.

Is this the intended behaviour of the catch node?

Example flow below:
[{"id":"5eeb1212.a114ec","type":"function","name":"throw error","func":"throw new Error(\"error!\");","outputs":"0","valid":true,"x":609.8889465332031,"y":350.8888854980469,"z":"762eff0a.89d1","wires":[]},{"id":"8e498c01.71b67","type":"inject","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":325.8888854980469,"y":349.8888854980469,"z":"762eff0a.89d1","wires":[["5eeb1212.a114ec"]]},{"id":"8bd3c819.742c38","type":"catch","name":"","x":314.8888854980469,"y":416.8888854980469,"z":"762eff0a.89d1","wires":[["d6967162.29699","5eeb1212.a114ec"]]},{"id":"d6967162.29699","type":"debug","name":"","active":true,"console":"false","complete":"false","x":606.8889465332031,"y":416.8888854980469,"z":"762eff0a.89d1","wires":[]}]

This email, and any attachments, is intended only for use by the addressee(s) named herein and may contain legally privileged and/or confidential information. It is the property of Telogis, Inc. If you are not the intended recipient of this email, you are hereby notified that any dissemination, distribution or copying of this email, any attachments thereto, and use of the information contained, is strictly prohibited. If you have received this email in error, please notify the sender and permanently delete the original and any copy thereof.

Dave C-J

unread,
Apr 23, 2015, 5:25:01 AM4/23/15
to node...@googlegroups.com

Nicholas O'Leary

unread,
Apr 23, 2015, 6:26:13 AM4/23/15
to Node-RED Mailing LIst
Hi Michael,

yes it is possible to get yourself into an infinite loop with the catch node. There are a couple of strategies for avoiding that. The main one is to put your error handling flow into a subflow with its own catch node inside. If the error recovery throws an error, the catch node in the subflow will get triggered and you can take an alternative route.

I think we can do more to avoid loops - its a new feature and sometimes they need trying out in the real world to figure this stuff out.

My current thought is to add the id of the catch node that handles the message to the error property of the message - we can then detect if a message is looping back to the same catch node and either ignore it, or log a warning or do something else.

If you have any thoughts as to how you'd like/expect it to work, I'm open to ideas.

Nick

On 23 April 2015 at 10:24, Dave C-J <dce...@gmail.com> wrote:

--
http://nodered.org
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nicholas O'Leary

unread,
Jun 15, 2015, 4:42:57 PM6/15/15
to Node-RED Mailing LIst
In the imminent 0.10.8 release, if a message is passed to a catch node from the same source node 10 times, then it is dropped and a warning logged. The theory here is that there are valid scenarios where you may want the message to loop through the catch node whilst retrying some action until it succeeds, so we don't want to rule out loops all together. Allowing 10 loops feels the right level for basic retry flows to work without any special measures needed. If a flow wants to retry more times, it simply has to delete the msg.error property (as that is what is used to track how many times it has passed through).

Nick


Reply all
Reply to author
Forward
0 new messages