Did I cause a loop in Node-Red?


I've started moving some of my nodes to Subflows. I thought it would be good to have some "unit tests" of those subflows inside the subflow itself. However, the second I hit Deploy, Node Red went out to lunch and never came back. I had to roll-back to fix it. So in summary, if subflow ABC contains a call of ABC, it looks like Node Red can't persist it, and will loop - correct? Note the call of ABC was not anywhere along the path of input-to-output, it was a separate sequence kicked off with an Inject node.



well depending on what the code was, it sure seems to me you could cause a loop. But you explaination leaves me confused. You have a subflow that does something and part of that something is to call itself? Without seeing the actual flow...???



Well I was in the process of reporting it as a bug (which it sort of is). The pic below is of the subflow called "Debug". You can't drag a Debug node into the Debug design because you get an error ("Cannot add subflow to itself"). However you can get it in there with copy/paste. First time around I assumed Node Red looped because once I hit deploy it never came back. However, in reproducing the problem, it all worked and deployed okay. So I'm not sure what happened first time around. Anyway, the Inject node is unclickable in a subflow, so I can't do what I wanted to anyway, which is a shame.



So what if you call the subflow 'MyDebug'?

p.s. while a picture may be worth a thousand words, the actual flow is far more helpful.



The fact the editor doesn't let you drag a subflow into itself should have been a clue. The bug is you were able to get an instance in there at all. Any subsequent misbehaviour is because the runtime doesnt support it.

If you can share details of exactly how you achieved that, we need to prevent it.



I think you just need to Ctrl+C an existing instance of the subflow, open the subflow, and paste it in. It allowed that, I didn't try deploying as I didn't want to lock things up.