Hi n8n community,
I’m facing an issue with nested loops in my n8n workflow, and I’d really appreciate your help in troubleshooting and resolving it. I’m using n8n to automate video creation, and my workflow involves iterating over 6 items in an outer loop and 5 items in an inner loop for each outer iteration. However, I’m encountering a problem where the inner loop works correctly in the first iteration of the outer loop but skips directly to the “Done” branch in the second iteration (and beyond) instead of iterating over the 5 items.
What I’m Trying to Achieve
I’m building a workflow to create 6 short videos, each with 5 random clips.
Here’s the structure:
Outer Loop (“Loop Create Video”): Iterates over 6 items (representing 6 titles, each with a videoIndex from 1 to 6).
Inner Loop (“Loop Clips”): For each title, iterates over 5 items (representing 5 random clips) to download the clips, save them to disk, and create a clips_.txt file.
After the inner loop completes, the workflow proceeds to create the final video for that title.
What I’ve Tried
I’ve verified that the “Choose 5 Random Clips” node outputs 5 items in every iteration of the outer loop, so the input to “Loop Clips” is correct.
I’ve checked the “Loop Clips” node settings:
Batch Size: 1 (default).
No additional options are set.
I’ve added logging to confirm that the outer loop is iterating correctly (it processes all 6 titles), but the inner loop skips iterations after the first one.
I’ve tested the inner loop independently (outside the outer loop), and it works fine, iterating over the 5 clips as expected.
My Setup
n8n Version: I’m running n8n on my VPS (self-hosted, latest version as of March 2025).
Environment: Docker container.
Questions
Why is the inner “Loop Clips” node skipping iterations after the first outer loop iteration and going straight to the “Done” branch?
How can I fix this so that the inner loop iterates over the 5 clips in every iteration of the outer loop, ensuring all 6 videos are created?
Is there a better way to structure this workflow to avoid this issue, perhaps by avoiding nested loops altogether?
Additional Information
I’ve attached a screenshot of the “Loop Clips” node’s output during the second iteration, showing that it goes straight to the “Done” branch with the 5 input items.
I’ve also attached the full workflow diagram for context.
I’m open to restructuring the workflow if there’s a more reliable approach (e.g., using sub-workflows or triggers), but I’d prefer to fix the nested loop if possible since it fits my current design.
Thank you in advance for your help! I’m really stuck on this and would appreciate any insights or suggestions from the community.
Best regards,
Mark