Infinit loop on loop node #2

Hello everyone!

I’m currently facing an issue with one of my workflows that seems to sometime be stuck in an infinite loop, and I can’t figure out what’s causing it.

I’ve set up a workflow that uses a loop node that splits in batches my flow to make http calls. (I split in batches because my http calls are pretty big and breaks n8n if all the calls are made at once)
n8n1

I tried to add a wait node at the end to add time between the loops, I tried to add an if node with " {{ $node[“Loop Over Items”].context[“noItemsLeft”] }} is false" But nothing fixed the issue.

I said sometime because, the flow is triggered automaticaly every day at 5am and some days it works and some others, the infinit loop accumulates too much data from I don’t know where and the memory runs out and the container shuts down.

I tried to add a wait node at the end to add time between the loops, I tried to add an if node with " {{ $node[“Loop Over Items”]. context[“noItemsLeft”] }} is false" But nothing fixed the issue.

I said sometime because, the flow is triggered automatically every day at 5am and some days it works and some others, the infinite loop accumulates too much data from I don’t know where and the memory runs out and the container shuts down.

I tried to re-execute the broken flow, and it worked so I really don’t know why sometime, the flow breaks. Is there some ways to debug flows that break like mine? I tried to visualize the broken executions even with execution data, but I can’t see any data.

I’m sorry, I’m new to n8n and don’t really know what to add to get better help.

Also, I am sorry, this is a repost because I thought the previous answer that was given to me worked. It worked for 2 days, but the third day, the flow broke again (with the fix that was given to me)

Thanks to all who will read me

Information on your n8n setup

  • **n8n version:**1.84.1
  • Database (default: SQLite): ?
  • n8n EXECUTIONS_PROCESS setting (default: own, main): ?
  • Running n8n via (Docker, npm, n8n cloud, desktop app): docker
  • **Operating system:**synology

hello @Plouf

I suppose it’s not infine, but rather an out of memory (OOM) issue.
Better to split the workflow and move the Loop part to the sub workflow. In that case, all child executions will release the memory once the execution finish. Currently, all data will be stored in the memory for each loop iteration, which eventually will cause the OOM issue.

1 Like

Hello and thank you for your reply.

I tried moving the part that downloads the pictures into a subworkflow. Here is the updated workflow:

I tried at first without the loop, but for some reason, it doesn’t send the inputs to the subworkflow. And even when it does, the subworkflow node never stops (even after running for an hour). I added the loop with batching set to 25 and activated the ‘Wait for Subworkflow Completion’ option, but now I’m facing the same problem as before:

n8n3

The loop sends and executes the subworkflows, but then it continues endlessly and never stops. I think one possible explanation could be that the Execute Workflow node is still somehow retrieving the pictures, even though I tried adding a Set node with nothing inside, like this:

Thanks again for the help !

I’m starting to lose my mind over this flow due to the loop and the fact that my work laptop isn’t very powerful. This flow is quite large, which makes the UI extremely slow whenever I try to work on it.

You can totally remove the loop node and set the Execute Workflow node to run for each item

1 Like

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