Issue with data retention between Two Loops in a Workflow

Hi n8n community,

I’m encountering an issue in a workflow that involves two loops: “Loop Aluno” (Student Loop) and “Loop Cobranças” (Charges Loop). The issue seems to arise because the “Loop Cobranças” node is retaining data processed during the previous iteration of “Loop Aluno”, rather than using the correct data from the current iteration.

Same is said here: Having an issue with looping (multiple loops in one workflow) - #6 by Imperol

Problem Description

  1. The workflow starts with the “Loop Aluno” node, iterating over a list of students.
  2. Inside “Loop Aluno”, there is a second loop called “Loop Cobranças”, which processes charges associated with each student. This second loop is fed by the Split Out node.
  3. During the first iteration of “Loop Aluno”, “Loop Cobranças” works as expected, processing the correct data and moving to the done branch after all charges are processed.
  4. However, during the second iteration of “Loop Aluno”, “Loop Cobranças” reuses the data from the first iteration instead of using the data from the Split Out node associated with the current student.
  5. Enabling the reset option on “Loop Cobranças” clears all data, but this prevents the workflow from reaching the done branch, which is required to complete the loop correctly.

Expected Behavior

  • The “Loop Cobranças” node should only process the data sent by the Split Out node for the current iteration of “Loop Aluno”.
  • When no items are left to process, “Loop Cobranças” should automatically move to the done branch, without reusing data from previous iterations.

Workflow Details

  • “Loop Aluno” configuration:
    • Type: Split In Batches
    • batchSize: Default configuration
  • “Loop Cobranças” configuration:
    • Type: Split In Batches
    • batchSize: 100
  • Other nodes in the workflow:
    • “Obter dados financeiros”: Fetches financial data for each student from a database.
    • “Aggregate”: Aggregates the financial data.
    • “Mais de 100?”: Checks if there are more than 100 items to process before splitting them.
    • “Split Out”: Splits the aggregated data into batches for the “Loop Cobranças” node.

Information on your n8n setup

  • n8n version: 1.57.0
  • Running n8n via (Docker, npm, n8n cloud, desktop app): desktop app
  • Operating system: Windows 11

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:

Welcome to the community @Vinicius_Mendonca !

Tip for sharing information

Pasting your n8n workflow


Ensure to copy your n8n workflow and paste it in the code block, that is in between the pairs of triple backticks, which also could be achieved by clicking </> (preformatted text) in the editor and pasting in your workflow.

```
<your workflow>
```

That implies to any JSON output you would like to share with us.

Make sure that you have removed any sensitive information from your workflow and include dummy or pinned data with it!


By default Loop node accepts only 1 set of items. To iterated over the 2nd set, the node has to be reset. Take a look at Loop Node Only Processes the First Item - How to Fix? - #10 by ihortom for more details.

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