Describe the problem/error/question
Hi everyone,
I have a polling loop in my workflow where I check the status of a long-running job. I noticed that every time the loop goes back to the Wait node and runs the HTTP Request (Status) again, n8n accumulates these runs as new items in the branch (e.g., 1 item, then 2 items, then 3 items total in the same execution branch).
I want to turn this “accumulation” into a feature instead of a bug.
My Goal: I want to use the total number of items currently in the active branch to act as my “Max Attempts” counter. For example, if the branch reaches 20 items, I want the loop to stop.
My Questions:
-
Is it a good practice to use
{{ $input.all().length }}inside an If or Switch node to limit the number of loops based on accumulated items? -
Does this accumulation impact performance if the loop runs for a long time (e.g., 50+ iterations)?
-
When the Split Out node moves to the next main item in the list, does n8n automatically “reset” this item count for the new branch, or will it keep adding to the previous total?
I’m trying to avoid using a separate Edit Fields (Set) node to manually increment a counter variable, as it feels redundant when n8n is already “counting” the runs by adding items.
Any advice on this “item-length-as-a-counter” approach would be great!
Please share your workflow
Share the output returned by the last node
Information on your n8n setup
- n8n version: 2.13.4
- Database (default: SQLite): SQLite
- n8n EXECUTIONS_PROCESS setting (default: own, main): main
- Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
- Operating system: Ubuntu 24.04





