Potential infinite loop in n8n
Why loops without proper exit conditions can freeze your workflow and crash n8n
What is this issue?
A potential infinite loop occurs when a workflow contains a loop structure (Split In Batches, Loop Over Items, or Code node with while/for) that lacks a clear termination condition. These loops can run forever, consuming all available memory and CPU.
Common causes:
•Loop condition that never becomes false•Recursive workflow calls without base case•Split In Batches processing items that regenerate•While loop in Code node with missing increment
Why is this dangerous?
Resource exhaustion
The loop consumes all available memory and CPU, eventually crashing the n8n instance.
Queue blocking
Other workflows cannot execute while an infinite loop monopolizes the worker.
Data corruption
Partial writes during a runaway process can leave your data in an inconsistent state.
Cost explosion
Cloud hosting charges accumulate rapidly when resources are consumed by a runaway loop.
How to fix it
- 1
Add explicit exit conditions
Ensure every loop has a clear termination condition that will eventually be met.
- 2
Set iteration limits
Add a maximum iteration count as a safety net (e.g., if iterations > 1000, break).
- 3
Configure workflow timeout
Set a timeout in workflow settings to automatically terminate runaway executions.
- 4
Add progress logging
Log iteration counts to detect when a loop is taking longer than expected.
Scan your workflow now
Upload your n8n workflow JSON and detect potential infinite loops and missing exit conditions.