Noob here with a question to which I can’t seem to find an answer via forum search: I have a workflow calling an API on different endpoints resulting in multiple branches. At the end of each branch, there is a check against a database to see if something has been inserted that needs to be enriched with data from other sources.
Is there a way to run this check at the end of each node but have it only defined once? Like a function call? When I use a merge node for example, it always waits for all input branches to finish. But I would prefer it to run as soon as one of its inputs delivers a result. I think this might be unwanted behavior (at least it seems like all solutions and examples out there do it differently), but my curiosity is sparked:
Is this somehow a bad idea? (I know about the “always output data” switch – but it is not that the other nodes don’t output data, but about them possibly not finishing at all.)
Is it possible without going the sub-workflow route which seems overly complicated to maintain and debug?
There is a “wait for all inputs to arrive” option in the merge node when configuring it to “choose branch” – but it’s the only option in the dropdown and cannot be deactivated. Does this work as intended?
Is there an alternative to the merge node I don’t know about which suits better to my “problem”?
Ensure to copy your n8n workflow and paste it in the code block, that is in between the pairs of triple backticks, which also could be achieved by clicking </> (preformatted text) in the editor and pasting in your workflow.
```
<your workflow>
```
That implies to any JSON output you would like to share with us.
Make sure that you have removed any sensitive information from your workflow and include dummy or pinned data with it!
If the check against each database is the same for the data in any branch, you can join all the branches at the input of the node that performs the check. This would imply
Check is done on the 1st come first checked bases
The otput of the database will contain as many sets of data (items) as the number of branches that were executed
The point 2 might be a problem or not depending on the further data processing needed.