Skip to content

BUG: Merge Node "Wait for both Inputs to arrive" is not waiting and gives false output #6596

Description

@prononext

For quite a long time I was trying to make a demo workflow to explain this strange behavior and finally I got it together.
The behavior seems simple but I find it quite hard to explain and to demonstrate. Sorry for the complication and I hope you understand it:

Inside a Batch I am using a IF Node to recognize a empty output (for instance on a HTTP Request node on which the requested dateframe has no output and then you want to get the next batch for the next dateframe.

But most times you use the Sort Node behind a HTTP Request node to split out fields or other Nodes where you cannot use the environments like {{ $json.column1 }} and just have to use the plain column name "column1".

To make the workflow continue on a positive output of the HTTP Request Node, needing to use a Sort node after it, you will get a error if you place the sort node behind the IF Node and if you place it before the IF node the workflow will not continue.

To solve this Problem I thought I can check with the IF Node for a empty item and if there is a empty item I continue to the next batch. If not I will route the If node with to a Merge Node with "Choose Branch / Wait for both Inputs to arrive" (Choosing Input 1) on Input 2 and Route the Node Output from before the IF Node to input 1 so the Batch will continue untill it reaches another point which will trigger the next batch.

But the Batch Node does not wait for both Inputs, it just fires a empty item, or the choosen output branch, regardless if both Inputs have arrived.

I noticed that behavior of the Merge node on several occations, not only in Split in Batches situations and it was running crazy 💯
I was using the Merge node on several similar occasions on very complex workflows and thought my data did was the point of error. I was thinking a long time how to explain it without having to make a too complex example, hopefully that is clear.

On this Screenshot it is clearly visible that the empty check IF Node has no output, but the Merge Node is behaving like it has a output.

image

**To Reproduce just use my Demo Workflow **

{
  "meta": {
    "instanceId": "12345"
  },
  "nodes": [
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "column1"
            },
            {
              "name": "column2",
              "value": "not-empty"
            }
          ]
        },
        "options": {}
      },
      "id": "2b3f8757-0c8f-4160-89a4-d3ac2530caf5",
      "name": "Column 1/2 empty",
      "type": "n8n-nodes-base.set",
      "typeVersion": 2,
      "position": [
        680,
        180
      ]
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "column1",
              "value": "not-empty"
            },
            {
              "name": "column2"
            }
          ]
        },
        "options": {}
      },
      "id": "25c133df-b2c1-4097-8141-d0adf1485eca",
      "name": "Column 2/2 empty",
      "type": "n8n-nodes-base.set",
      "typeVersion": 2,
      "position": [
        680,
        320
      ]
    },
    {
      "parameters": {},
      "id": "4a7648f2-bdc4-4c3b-a1cc-eb6ebc9a968d",
      "name": "Append",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 2.1,
      "position": [
        900,
        260
      ]
    },
    {
      "parameters": {
        "batchSize": 1,
        "options": {}
      },
      "id": "eadc9da8-689a-4aec-adc3-23f0f4adc5f3",
      "name": "Split In Batches of 1",
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 2,
      "position": [
        1060,
        260
      ]
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{ $json.column1 }}",
              "operation": "isNotEmpty"
            }
          ]
        }
      },
      "id": "74626e43-298f-4bd2-812b-2ad33cd3e777",
      "name": "Empty Check",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        1560,
        260
      ]
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "column3",
              "value": "not-empty"
            },
            {
              "name": "column4",
              "value": "not-empty"
            }
          ]
        },
        "options": {}
      },
      "id": "b12c0f8c-d5b3-460a-98c4-6aee4a122aa6",
      "name": "Column 3+4 add",
      "type": "n8n-nodes-base.set",
      "typeVersion": 2,
      "position": [
        1240,
        260
      ]
    },
    {
      "parameters": {},
      "id": "3e00f80e-bb8d-409e-99db-0b2a2d47b8e9",
      "name": "START",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        460,
        240
      ]
    },
    {
      "parameters": {},
      "id": "9219a0f1-a686-4d08-981c-9573a5d5772a",
      "name": "STOP",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        1800,
        480
      ]
    },
    {
      "parameters": {
        "keepOnlySet": true,
        "options": {}
      },
      "id": "3461ec69-dd67-4945-9358-02e5fe84f2c1",
      "name": "Insert Empty Item",
      "type": "n8n-nodes-base.set",
      "typeVersion": 2,
      "position": [
        1400,
        260
      ]
    },
    {
      "parameters": {},
      "id": "b5b5d9e4-c07c-495d-bb9a-46feb4c90765",
      "name": "Click on Execute",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        300,
        240
      ]
    },
    {
      "parameters": {
        "mode": "chooseBranch"
      },
      "id": "4329ce10-2428-48b2-a3d2-c457da7c058a",
      "name": "Faulty Merge",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 2.1,
      "position": [
        1780,
        20
      ]
    }
  ],
  "connections": {
    "Column 1/2 empty": {
      "main": [
        [
          {
            "node": "Append",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Column 2/2 empty": {
      "main": [
        [
          {
            "node": "Append",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Append": {
      "main": [
        [
          {
            "node": "Split In Batches of 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split In Batches of 1": {
      "main": [
        [
          {
            "node": "Column 3+4 add",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "STOP",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Empty Check": {
      "main": [
        [
          {
            "node": "Faulty Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Column 3+4 add": {
      "main": [
        [
          {
            "node": "Insert Empty Item",
            "type": "main",
            "index": 0
          },
          {
            "node": "Faulty Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "START": {
      "main": [
        [
          {
            "node": "Column 1/2 empty",
            "type": "main",
            "index": 0
          },
          {
            "node": "Column 2/2 empty",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Insert Empty Item": {
      "main": [
        [
          {
            "node": "Empty Check",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Click on Execute": {
      "main": [
        [
          {
            "node": "START",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Faulty Merge": {
      "main": [
        [
          {
            "node": "Split In Batches of 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Expected behavior
The Merge node should wait till BOTH Inputs have arrived. If not both inputs arrive it should do nothing.

Environment :

  • OS: Ubuntu Linux 22.04
  • n8n Version 0.233.1
  • Node.js Version v16.20.0

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