How to execute multiple paths simultaneously from a single trigger node? Only one path is run now

Describe the problem/error/question

I have a workflow which I want to run manually. I have initial “When clicking test execution” node, from which I have two arrows. The intent is to have both of them run (because later on I merge the data they fetch).

However, when I start the workflow with ‘Test execution’, only one of those two nodes run, and the workflow fails in the node where two paths join, with a message “Referenced node is unexecuted”.

How do I tell n8n that I want to walk all the output arrows from all nodes?

Here is my workflow

It should:

  • load gmail labels in one flow (for a label name → label id lookup)
  • and load gmail messages in a second flow, then loop over them (in batches of 5, otherwise the flow fails as there is too much data between the nodes) with the following code (that adds new label to each email, so that the following step can set gmail label id for a given message id).

The code:

const allLabels = $('Gmail: read labels').all()
const idFromLabelName = allLabels.reduce((o, label, i) => {
  o[label.json.name] = label.json.id
  return o
}, {})


const emails = $('Loop Over Items').all()
const assignedLabels = $('Classify email').all()
console.log({emails, assignedLabels, idFromLabelName})

// Loop over input items and add a new field called 'myNewField' to the JSON of each one
emails.forEach((email, i) => {
  const assignedLabelName = assignedLabels[i].json.text
  email.json.assignedLabelName = assignedLabelName
  email.json.assignedLabelId = idFromLabelName[assignedLabelName]
  console.log(`Added label ${assignedLabelName} to email "${email.json.subject}"`)
})

return emails; // $input.all();

I was expecting n8n to realize that it executed the first flow up to a point where it needs input from the second one, and so it should run the second flow, but right now the only way to run this flow is to manually click the ‘run’ button for each item in order.

I tried searching from “Referenced node is unexecuted”, which I would expect people with similar problem to run into, but no dice so far, even though this seems like a trivial omission.

Thanks!

Share the output returned by the last node

Information on your n8n setup

  • n8n version: 1.73.1
  • Database (default: SQLite): SQLite
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: Ubuntu

Welcome to the community @tkafka !

Tip for sharing information

Pasting your n8n workflow


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!


Judging by the screenshot, the lower branch did not run becuase th eupper branch failed midway terminating the whole execution prematurely.

Also I spotted incprrect usage of Loop node. Your loopback connection has to connect the input of the Loop node but it goes to LLM node instead.

Hi @tkafka

Based on your image, when you split a workflow like this, only one branch will run at a time. So the lower branch will not run until the top one has completed and as that is failing at the code node (because the bottom branch has not run yet), the bottom branch won’t run.

Also, the loop needs to come back to the loop node and not the LLM as you have now.

Depending on what you are trying to do, a couple of suggestions:

  1. Split the branches as you have and run the 2 GMail nodes then use a Merge node to bring them both together and see if you can create the rest of the workflow that way.
  2. Another way might be to run your getAll: message node then create the loop after that, incorporating your getAll: label, LLM and Code Node, addLabel Node and Slack Node into the loop. Remember to close the loop back to the Loop node.

Hopefully one of these 2 will get you a little closer.

Thank you!

  1. I had a wrong mental model, there is no parallelization.
  2. However, the core issue I was tackling was that:
  • I fetched X (or had it as a workflow input) - read messages
  • Then I fetched Y - read labels
  • And now I wanted to iterate X (messages) again

I solved by adding a code step like this, that takes X from the previous steps, and exposes it as a result.

return $('Previous step name').all()


It is a hacky workaround for n8n seemingly unable to select which of the inputs I want to iterate on, but it works for me.

Is there a better way to do this? I expected the ‘iterate’ step to have a picker of what input I want to iterate on, but it seems to have hardcoded previous’ step’s output as its input.

1 Like

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