Why this feedback loop does not work?

Hello, I’m getting confused about working with feedback loops in n8n.
Consider for instance the following Workflow:

This in my intention should:

  • Define a JSON with two fields: iterationNumber (Number) and previousIterations (Array)
  • Increment iterationNumber and append the previous iterationNumber to previousIterations at each iteration

However, while everything seems to work correctly to the block “Edit Fields1” where the JSON is

[
  {
    "iterationNumber": 2,
    "previousIterations": [
      1
    ]
  }
]

When the loop starts again (at the No-Op block), it takes the very first JSON values:

[
  {
    "iterationNumber": 1,
    "previousIterations": []
  }
]

I hope I made my question clear :slight_smile:

  • n8n version: 1.90.2
  • Database (default: SQLite): SQLite
  • n8n EXECUTIONS_PROCESS setting (default: own, main): own, main
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: macOS 15.4.1

You most likely execute nodes 1 by 1 following the flow.
You need to run the entire workflow. However :no_entry: it is not recommended as the loop is endless and will eventually consume memory and crash the server.
Consider adding an If node with a condition to terminate the loop at some iteration value before testing the entire flow in a single full execution.
If this resolves your question, please mark this post as a :white_check_mark: Solution.

But why it doesn’t work if I run manually one node at a time? This is the whole point of doing that BTW, to check how the process goes on in a “debug mode” (sort of)

Thank you!

You can run one node at a time, but you need to pin data to the previous node.

SInce the workflow is all meant to work together, each node relies on the one before it for the input data. If you go in and click the pencil icon you can edit mock data to save to do that

I don’t understand: if a node has the possibility to have two nodes at its input, why when running everything manually step-by-step it ignores the latest input data?

it can be a little finicky.

If you want the assurance that a node won’t run again until you want it to, if it just ran you can press P on the keyboard and that’s the shortcut to pin the data that’s currently in it

Fair point. Worth n8n team looking into it.

Apparently this is not working as you describe, in my scenario.

Thank you

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