N8n Issue: Items in a Branch Are Not Processed Independently

I am currently facing a challenge with n8n and need help from the community. Here’s the context:

I am trying to iterate through all leads stored in a Supabase table and execute a query for each lead to match them with emails stored in another table. Initially, I attempted to achieve this using the Loop node, which seemed to work, but I couldn’t figure out how to make it iterate through the entire table. Eventually, I designed the workflow described below, which works fine except for a strange issue with how items are handled in one of the branches.

Here’s what happens:

  1. In the ‘Get leads’ node, I set a limit of 3. This returns the following leads:
  • Lead 1: { id: 3320 }
  • Lead 2: { id: 7444 }
  • Lead 3: { id: 9755 }
  1. In the subsequent ‘Code’ node, I prepare queries for each lead, resulting in three items:
  • Item 1: { id: 3320, query: “Has one matching email in database, id: 33881” }
  • Item 2: { id: 7444, query: “No matching emails in database” }
  • Item 3: { id: 9755, query: “Has one matching email in database, id: 34528” }
  1. Now, we step into the ‘Set lead ID for the matching emails’ node. I expect this node to run an update query for each item individually, so at the end, I should have email 33881 connected to lead 3320 and email 34528 connected to lead 9755.

However, this is not what happens. Instead, the output looks like this:

[
  {
    "id": 33881,
    "lead_id": 3320
  },
  {
    "id": 33881,
    "lead_id": 7444
  },
  {
    "id": 33881,
    "lead_id": 9755
  }
]

And when I check the database, email 33881 is connected to lead 9755.

My understanding is that each node in n8n should process items individually within its own context. I was expecting each item to be handled independently, but it seems like the same email ID (33881) is being used across all leads.

Is this a bug in n8n? Or am I misunderstanding how the item processing works in n8n workflows?

I would really appreciate any insights or guidance on this issue. Thanks in advance!

The workflow:

Information on your n8n setup

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

I found a stupid-simple solution that works — I just set the limit for the ‘Get Leads’ node to 1.

Nevertheless, I’m still curious: is this a bug, or am I misunderstanding something about how n8n works?

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