Skip to content

loop over items node repeatedly done #16263

Description

@ltx0633

Bug Description

Loop repeats excuted done

Image

To Reproduce

{
  "nodes": [
    {
      "parameters": {},
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        -1200,
        260
      ],
      "id": "876f21f3-98c7-48f0-adff-f809b83f499a",
      "name": "When clicking ‘Execute workflow’"
    },
    {
      "parameters": {
        "options": {
          "reset": false
        }
      },
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        -540,
        260
      ],
      "id": "24b4278d-0238-4b6e-885a-340407910bef",
      "name": "Loop Over Items"
    },
    {
      "parameters": {
        "jsCode": "// Loop over input items and add a new field called 'myNewField' to the JSON of each one\nfor (const item of $input.all()) {\n  item.json.myNewField = 1;\n}\n\nreturn {\"json\": \n   {\n     \"output\": [ 1 ,  2 , 3  ]\n   }\n  }"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -980,
        260
      ],
      "id": "706ad702-08d0-43ae-b025-3cada9d0d996",
      "name": "Code"
    },
    {
      "parameters": {
        "fieldToSplitOut": "output",
        "options": {}
      },
      "type": "n8n-nodes-base.splitOut",
      "typeVersion": 1,
      "position": [
        -760,
        260
      ],
      "id": "bb0425bc-6489-4d10-a185-fd5339197906",
      "name": "Split Out"
    },
    {
      "parameters": {
        "url": "https://www.example.com",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        740,
        380
      ],
      "id": "f1b7876c-53d4-48e9-9d8b-b607268721fe",
      "name": "HTTP Request",
      "executeOnce": true
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.limit",
      "typeVersion": 1,
      "position": [
        40,
        60
      ],
      "id": "d9f6bd11-6b1c-479a-93c4-cc9bf16d5639",
      "name": "Limit"
    },
    {
      "parameters": {
        "jsCode": "// Loop over input items and add a new field called 'myNewField' to the JSON of each one\nfor (const item of $input.all()) {\n  item.json.myNewField = 1;\n}\n\nreturn $input.all();"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        40,
        260
      ],
      "id": "f917f2f3-4ccf-4e05-a16d-f614f83b13d9",
      "name": "Code1"
    },
    {
      "parameters": {
        "jsCode": "// Loop over input items and add a new field called 'myNewField' to the JSON of each one\nfor (const item of $input.all()) {\n  item.json.myNewField = 1;\n}\n\nreturn $input.all();"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        40,
        400
      ],
      "id": "aa9c644a-73c5-4c48-baef-9997d9ae82ea",
      "name": "Code2"
    }
  ],
  "connections": {
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [
          {
            "node": "Limit",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Code1",
            "type": "main",
            "index": 0
          },
          {
            "node": "Code2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code": {
      "main": [
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Limit": {
      "main": [
        []
      ]
    },
    "Code1": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code2": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "meta": {
    "instanceId": "1017af5f7ed62f1a3962a7eaf020673818f11345b1b22104e21365694517e330"
  }
}

Expected behavior

Executed only once "done"

Operating System

macos

n8n Version

1.97.1

Node.js Version

v20.19.2

Database

SQLite (default)

Execution mode

main (default)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions