đź’ˇ Have your say - help us improve the loop over items node!

Hello n8n community :wave:

We’re looking at ways to improve our Loop Over Items (Split in Batches) node and would love to get your input.

  • Have you run into any annoyances when creating loops in n8n?
  • Does the loop over items node behave as you expect it to?
  • Any suggestions for how you wish this node would function, or features you think are missing?

The more detailed feedback you have the better! Screengrabs and linked workflows are always helpful.

Thanks in advance for helping us improve n8n,
Jake - Senior Product Designer, Nodes Team

10 Likes

Please remove the “Replace Me” node. I hate it with a passion.
Having to delete 2 things every time you add a loop node is very annoying. (delete the node and the looping arrow/edge)

One of the features I added in my community node is the option to execute whatever is inside this loop inside a subworkflow.
And also a configurable reduced number of items for a manual execution. ( that does then continue to the done branch after this subset was executed)

21 Likes
  • Add an option to add an $json.iteration (0, 1, 2, 3, …) to the item.
  • Add an option for start (if this makes sense in the Loop node)
10 Likes

I often read nested loops cause issues, perhaps we can address that too?

10 Likes

Maybe pinning data (1 batch) for testing purposes. The challenge would be to match the batch size that may get changed during the develop-and-test cycle. Disregarding the batch size setting would work for me.

6 Likes

Yea, you need to use this $prevNode and if you change the $prevNode and forget to fix it you wonder why it’s not work :slight_smile: :laughing: Just make the reset easier!

2 Likes

I experienced loss of reference when I’m 8+ nodes down the line in a loop. I can’t call the {{ $('Loop Over').item.json.url}} item, it doesn’t know what the current item is.

4 Likes

I’ve also experienced loss of reference in long workflows with a loop in the middle.

I don’t know how to replicate this, but it’s happened quite a few times.

2 Likes

Probably has to do with a certain node used. For example code or http request.
Using. .item is always with its risks and if it cannot find the paired item because it is lost/removed it will not work.
Personally I never use it only use all(), first() and last() as you always know exactly what u are getting.
If you need related items use a merge.

1 Like

Allow pinning of output data so that users aren’t forced to endure endless loops in order to test their workflow each time.

1 Like

I’m so happy you’re working on this @Jake.

1. Nested Loops

Nested loops send data to the done branch instead of the loop branch. The following workflow illustrates this issue. Both Loop nodes have a batch of 1 in this minimalist example.

I have been using workarounds with sub-workflows and Code nodes.

2. Loop Run Index

Could you make the currentRunIndex more accessible to others? I’ve been using {{ $('Loop over batch').context.currentRunIndex }} to keep tabs on the iterations and manage batches.
This is an undocumented feature but it’s very useful.

Thanks,
Andrew

8 Likes

Yeah, I’ve found many workarounds for this issue.
But I had never heard of someone never using .item

That is very interesting. I have no idea how this would work, but I’ll experiment a little.

I started using n8n before we had the paired items. and when it was introduced it was not reliable yet.
Also after I don’t like using workarounds. As it will always be more difficult to maintain properly.

1 Like

I remember looking for it and I found it in the docs but in the UI there is no suggestions for the context of the loop node.

Also adding max iterations and a break condition would be useful

Edit: I think you can do both with a simple js expression in an If node now but most people wouldn’t probably be able to figure it out.

Thanks a ton for all the input so far everyone! Many of these points are already on our radar but it’s good to hear them echoed again alongside some new ideas as well

I have wished the UI would leave no option for failing to “close” the loop, and make it clearer that every item going into the loop should go through to the end somehow (since putting an If or a Filter in the middle of a loop seems to be just as troublesome as nesting another loop. Sometimes the solution to that is to pull the the steps in the loop entirely out into a callable sub-workflow, making it a single step, but then tracing through executions becomes more challenging.

From what I can tell, the main reason for using a loop-over-items is to avoid the “process everything right now, in one go” behavior you get from a node, with a list of items.

What if loop-over-items were changed to an in-workflow “batchable” sub-process.

3 Likes
  1. add error output data ,if is active instead of interrupt the loop put the item with issue in the error output and move on to the other items
  2. Add an offset settings to skip one or more items in the loop
  3. add a execution time option for interrupt a loop if exceed specific time
  4. add mockup data for set custome json element for testing loop
  5. add an option for reverse loop, loop node wait all items and start from last items
2 Likes

I would like to have an option in the loop configuration so that instead of receiving all the results of the loop, I could only receive a completion status.

This would make the response cleaner as a trigger for another action. :grinning:

first issue - the way the nodes reflect items counts is really wacky – consider nested loops - if a single item running thru the loop creates 4 sub items like a split and we loop over those 4 items – the counts somehow explodes into hugh numbers … its like a cartesian product … –
see the example – 15 items main loop - for each item in the main loop, i created 4 items and action them, then return to the main loop. where does the 480 come from.
second related issue - looks like the loop outputs are kept in the different runs - great but counting them and displaying that is not as useful - imho nobody loops over 1000s of items to collect them to then do something after , yes, they can but in practice, collection large number of items can in some cases cause OOM as well as complete loss of all the items if something fails … we batch cuz we can to do things step wise n commit and loop (just 1 way to handle item processing)

1 Like