Problem with nested SplitInBatches loops – inner loop only runs for first iteration

Describe the problem/error/question

I’m building a workflow with two nested loops, both using SplitInBatches.

The outer loop runs correctly over all items, but the inner loop only executes for the first iteration of the outer loop.

On subsequent iterations, the inner loop is skipped and immediately goes to the “Done” output, even though valid input data is being passed.

What is the error message (if any)?

There is no error message — the workflow simply skips the inner loop for iterations beyond the first.

Please share your workflow

Information on your n8n setup

  • n8n version: 1.107.4
  • Running n8n via Docker (Kubernetes)
  • Operating system: Linux

I remembered this has 2 solutions:

  1. doing some complicated expression in the loop reset option.
  2. Make the inner loop as a sub workflow

I think you can try with the second option.

Hello @Bringasher

Thanks for your answer.

When I enable the “Reset” flag on the sub-loop node, during the first iteration of the main loop, the sub-loop never stops iterating.

Here is the updated workflow where this happens:

Thanks in advance for your help :slightly_smiling_face:

Hello @darrell_tw

Thanks for your answer.

I’ll try using a sub-workflow for the inner loop.

That said, it’s a bit surprising that a tool like n8n doesn’t handle nested loops more easily out of the box.

You’d expect something as common as nested SplitInBatches to work without special tricks or restructuring.

Thanks again for your help!

Put the second one into a sub-workflow. In main-workflow, make a set node just before sub-workflow and set all the parameters needed to pass to the sub, at sub-workflow return the fewest possible parameters to the main. Memory gets cleared once a sub is done