Code Node Runs Multiple Times Instead of Returning One Merged Item

Hey everyone,

I’m trying to merge multiple nodes in that return a different number of items. At the end, I want to collect all items into a single list so I can process them together.

To achieve this, I’m using a Code Node with “Run Once for All Items” enabled. My approach is to gather all the items from different nodes, merge them, and return a single item. However, instead of returning just one merged item (seemingly once per connected node), the Code Node executes multiple times

Expected:

:white_check_mark: Runs once and returns one merged item

Actual:

:x: Runs multiple times, returning multiple items

Question:

How do I ensure the Code Node runs only once and returns one merged item? Any ideas?

Thanks! :blush:

It looks like your topic is missing some important information. Could you provide the following if applicable.

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

Hey @S_v_e_n , that is expected behaviour. You have two separate inputs (sets) with 2 items in each - one comes from top branch and the other from the bottom. The top branch executes first and Code node processes its data. Then the bottom branch executes and Code node is called 2nd time processing the data passed over to it by the bottom branch. As a result the Code node has 2 iterations (calls) processing 2 items with each iteration.

If you need to merge data use Merge node.

1 Like

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