🔥 [Solution Found] Split In Batches always repeats the first item? Here’s the fix!

Hi everyone,

I wanted to share a little discovery that cost me 3 days of headaches :sweat_smile: — hopefully it can save others some time.

The problem:
When using Split In Batches to process items one by one, I noticed something strange:
:backhand_index_pointing_right: My Notion records (or other actions) were always taking the data from the first item only, even if multiple distinct events/items were coming from my trigger.

Why this happens:
Nodes further down the workflow were still pointing directly to the Trigger node (e.g. Google Calendar). Since n8n “reuses” item 0 from the trigger, it looked like every batch iteration was sending the same data.

The solution (super simple!):
Right after Split In Batches, inside the loop, add a tiny Code node with:

return items;

This node “re-emits” the currently active batch item as the local reference.
From there, just use this Code node as your data source (instead of the Trigger).

Result: each item finally carries its own data correctly :tada:


:white_check_mark: Quick recipe:

  1. Trigger (e.g. Google Calendar)

  2. Split In Batches

  3. Code node → return items;

  4. Your requests (HTTP, Notion, etc.) → everything works perfectly


Hope this helps anyone stuck with the same issue.
For me, this tiny trick completely unblocked my workflow :rocket:

Hi @Smooky

I moved the topic to the right category, as this doesn’t seem to be a feature request :wink:

Also I have no idea what you are doing here but I think the issue is your workflow design and not really a fix that is needed with the code node like this.
Can you share what you were actually doing and solved with this? Maybe we can give u the proper way of fixing it, or you did find an issue and it can be fixed by the team.

Ps. return items; is an old function, I didn’t even know you could still use. You should probably replace it by return $input.all(); to make sure it doesn’t break at some point.

What he’s trying to say is the same thing that’s been happening to me in a self-hosted instance on Windows (node.js).

As you can see in the attached screenshot, when I split out a payload received with several items and then separate the array into unique items, the Node splitout is repeating the first item ([0]).

In my case, 50 records were received, but only 45 were separated. Seven of them were the first repeated item. Looking at the attached image, it’s easy to understand.

This topic is a bit confusing, so I’ll try to clarify things.
First of all, Split Out and Split in Batches (also known as “loop over items”) are different nodes with different purposes.

@Carlos_Guimaraes, I couldn’t fully understand what you were trying to do, but Split Out separates items inside an array. In your case, based on the attached image, the items were already separated — so you might be using the wrong node for what you want to achieve.

@Smooky, I remember having a similar issue. If I’m not mistaken, it can happen when you take an item from outside the loop and try to use it inside the loop. If that’s the case, it’s usually better practice to create a Set node that attaches the needed information to every item before they enter the loop.

Your workaround of adding a Code node that simply returns items can also work, since it forces the current batch item to become the local reference inside the loop. However, depending on the workflow structure, it might also introduce new issues — especially if other nodes still reference data from outside the loop. Because of this, preparing all needed fields in a Set node before the loop tends to be a more stable and predictable solution.