Wait for result of two branches

I have a flow that HTTP gets a web page, and parses out two bits of the HTML using HTML nodes.
I then need to process the results of those two parses.
Currently, I'm storing result 1 into a flow variable, and then delaying 0.5 sec on the other branch (to make sure the first part completes), before proceeding to the function node that uses msg.payload from the second branch and the stored flow variable from the first branch...

I know there are some contributed AND gates, but I want to do this with vanilla node-red... is this totally reliable, how short can I make the delay node, and... is there a better way?

Look at the [JOIN] node

2 Likes

just put the result of the first parse into a different message property, lets say msg.parse1, then pass this result to the next html node, then you have both results in one message, which you could process with your function node. No delays, no storage, no race conditions etc...

EDIT: sorry, I was too fast, you would also need to have the result of your http message stored in the message, so two more change nodes would be necessary:
http node -- change node -- html node -- change node -- html node -- function node

ooh, yes - thanks - I'd forgotten [JOIN] has all those extra features now :grinning:

also good - thanks - hadn't thought of that

interestingly, if I look back at my very old flows, I often also did some kind of "parallel" processing and then joining the results together. Nowadays I hardly do that, since nearly all of those situations can be solved when chaining nodes together. This is also a more flow like programming pattern. Only in situations where there might be some long running async calls I still use branching and joining flows.

2 Likes