N8n executions on loop causing error

All of a sudden single execution is running multiple times.

Making Multiple Entries in MySQL Database, Multiple push in Gotify.

n8n version: 0.93.0

Gotify:

My Workflow:

{
  "nodes": [
    {
      "parameters": {
        "email": "={{$node[\"WooCommerce Trigger\"].json[\"billing\"][\"email\"]}}",
        "listId": 15,
        "additionalFields": {
          "customFieldsUi": {
            "customFieldsValues": [
              {
                "key": 1,
                "value": "={{$node[\"WooCommerce Trigger\"].json[\"billing\"][\"first_name\"]}}"
              },
              {
                "key": 2,
                "value": "={{$node[\"WooCommerce Trigger\"].json[\"billing\"][\"last_name\"]}}"
              },
              {
                "key": 5,
                "value": "={{$node[\"WooCommerce Trigger\"].json[\"billing\"][\"phone\"]}}"
              },
              {
                "key": 10001,
                "value": "={{$node[\"Generate New Key\"].json[\"api_key\"]}}"
              },
              {
                "key": 10002,
                "value": "={{$node[\"Prepare to Proceed\"].json[\"user_domain1\"]}}"
              },
              {
                "key": 10003,
                "value": "={{$node[\"Prepare to Proceed\"].json[\"user_domain2\"]}}"
              },
              {
                "key": 10004,
                "value": "={{$node[\"Prepare to Proceed\"].json[\"user_domain3\"]}}"
              },
              {
                "key": 10005,
                "value": "={{$node[\"Date Of Purchase\"].json[\"DOP\"]}}"
              },
              {
                "key": 10006,
                "value": "={{$node[\"Date of Expiry\"].json[\"DOE\"]}}"
              }
            ]
          },
          "status": "ACTIVE",
          "tags": [
            "pm purchase"
          ]
        }
      },
      "name": "Automizy",
      "type": "n8n-nodes-base.automizy",
      "typeVersion": 1,
      "position": [
        2260,
        260
      ],
      "credentials": {
        "automizyApi": "Automizy BLP"
      },
      "disabled": true
    },
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        100,
        140
      ]
    },
    {
      "parameters": {
        "event": "order.created"
      },
      "name": "WooCommerce Trigger",
      "type": "n8n-nodes-base.wooCommerceTrigger",
      "typeVersion": 1,
      "position": [
        170,
        380
      ],
      "webhookId": "a6781718-8f00-4c4c-abbb-42e5aa54f7f1",
      "credentials": {
        "wooCommerceApi": "Store WooCommerece"
      }
    },
    {
      "parameters": {
        "resource": "order",
        "operation": "update",
        "orderId": "={{$node[\"WooCommerce Trigger\"].json[\"id\"]}}",
        "updateFields": {
          "status": "completed"
        },
        "billingUi": {
          "billingValues": {
            "firstName": "={{$node[\"WooCommerce Trigger\"].json[\"billing\"][\"first_name\"]}}",
            "lastName": "={{$node[\"WooCommerce Trigger\"].json[\"billing\"][\"last_name\"]}}",
            "email": "={{$node[\"WooCommerce Trigger\"].json[\"billing\"][\"email\"]}}",
            "phone": "={{$node[\"WooCommerce Trigger\"].json[\"billing\"][\"phone\"]}}"
          }
        }
      },
      "name": "WooCommerce",
      "type": "n8n-nodes-base.wooCommerce",
      "typeVersion": 1,
      "position": [
        640,
        250
      ],
      "credentials": {
        "wooCommerceApi": "Store WooCommerece"
      }
    },
    {
      "parameters": {
        "email": "={{$node[\"WooCommerce Trigger\"].json[\"billing\"][\"email\"]}}",
        "listId": 15,
        "additionalFields": {
          "customFieldsUi": {
            "customFieldsValues": [
              {
                "key": 1,
                "value": "={{$node[\"WooCommerce Trigger\"].json[\"billing\"][\"first_name\"]}}"
              },
              {
                "key": 2,
                "value": "={{$node[\"WooCommerce Trigger\"].json[\"billing\"][\"last_name\"]}}"
              },
              {
                "key": 5,
                "value": "={{$node[\"WooCommerce Trigger\"].json[\"billing\"][\"phone\"]}}"
              },
              {
                "key": 10001,
                "value": "={{$node[\"Generate New Key\"].json[\"api_key\"]}}"
              },
              {
                "key": 10002,
                "value": "={{$node[\"Prepare to Proceed\"].json[\"user_domain1\"]}}"
              },
              {
                "key": 10003,
                "value": "={{$node[\"Prepare to Proceed\"].json[\"user_domain2\"]}}"
              },
              {
                "key": 10004,
                "value": "={{$node[\"Prepare to Proceed\"].json[\"user_domain3\"]}}"
              },
              {
                "key": 10005,
                "value": "={{$node[\"Date Of Purchase\"].json[\"DOP\"]}}"
              },
              {
                "key": 10006,
                "value": "={{$node[\"Date of Expiry\"].json[\"DOE\"]}}"
              }
            ]
          },
          "status": "ACTIVE",
          "tags": [
            "pm purchase"
          ]
        }
      },
      "name": "Automizy",
      "type": "n8n-nodes-base.automizy",
      "typeVersion": 1,
      "position": [
        2260,
        260
      ],
      "credentials": {
        "automizyApi": "Automizy BLP"
      },
      "disabled": true
    },
    {
      "parameters": {
        "table": "api_key",
        "columns": "purchase_id, uid, name, email, phone, user_key, dop, doe, user_domain1, user_domain2, user_domain3, status, last_payment, purchase_type"
      },
      "name": "MySQL",
      "type": "n8n-nodes-base.mySql",
      "typeVersion": 1,
      "position": [
        1790,
        250
      ],
      "executeOnce": false,
      "credentials": {
        "mySql": "Singapore DB"
      }
    },
    {
      "parameters": {
        "jsonParameters": true,
        "options": {}
      },
      "name": "Generate New Key",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        1260,
        250
      ]
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{$node[\"WooCommerce Trigger\"].json[\"line_items\"][0][\"product_id\"]}}",
              "operation": "contains",
              "value2": "79"
            }
          ]
        },
        "combineOperation": "any"
      },
      "name": "IF Product ID is 12",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        420,
        380
      ]
    },
    {
      "parameters": {},
      "name": "NoOp",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        600,
        550
      ]
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "purchase_id",
              "value": "={{$node[\"WooCommerce Trigger\"].json[\"id\"]}}"
            },
            {
              "name": "email",
              "value": "={{$node[\"WooCommerce Trigger\"].json[\"billing\"][\"email\"]}}"
            },
            {
              "name": "phone",
              "value": "={{$node[\"WooCommerce Trigger\"].json[\"billing\"][\"phone\"]}}"
            },
            {
              "name": "firstname",
              "value": "={{$node[\"WooCommerce Trigger\"].json[\"billing\"][\"first_name\"]}}"
            },
            {
              "name": "lastname",
              "value": "={{$node[\"WooCommerce Trigger\"].json[\"billing\"][\"last_name\"]}}"
            },
            {
              "name": "name",
              "value": "={{$node[\"WooCommerce Trigger\"].json[\"billing\"][\"first_name\"]}} {{$node[\"WooCommerce Trigger\"].json[\"billing\"][\"last_name\"]}}"
            },
            {
              "name": "dop",
              "value": "={{$node[\"Date Of Purchase\"].json[\"DOP\"]}}"
            },
            {
              "name": "doe",
              "value": "={{$node[\"Date of Expiry\"].json[\"DOE\"]}}"
            },
            {
              "name": "user_domain1",
              "value": "={{$node[\"Function\"].json[\"url1\"]}}"
            },
            {
              "name": "user_domain2",
              "value": "={{$node[\"Function\"].json[\"url2\"]}}"
            },
            {
              "name": "user_domain3",
              "value": "={{$node[\"Function\"].json[\"url3\"]}}"
            },
            {
              "name": "user_key",
              "value": "={{$node[\"Generate New Key\"].json[\"api\"]}}"
            },
            {
              "name": "status",
              "value": "active"
            },
            {
              "name": "last_payment",
              "value": "={{$node[\"WooCommerce Trigger\"].json[\"date_created\"]}}"
            },
            {
              "name": "purchase_type",
              "value": "={{$node[\"WooCommerce Trigger\"].json[\"coupon_lines\"][0][\"meta_data\"][0][\"display_value\"][\"code\"]}}"
            }
          ]
        },
        "options": {}
      },
      "name": "Prepare to Proceed",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        1610,
        250
      ]
    },
    {
      "parameters": {
        "value": "={{$node[\"WooCommerce Trigger\"].json[\"date_paid\"]}}",
        "dataPropertyName": "DOP",
        "custom": true,
        "toFormat": "YYYY-MM-DD",
        "options": {
          "fromTimezone": "UTC"
        }
      },
      "name": "Date Of Purchase",
      "type": "n8n-nodes-base.dateTime",
      "typeVersion": 1,
      "position": [
        840,
        250
      ]
    },
    {
      "parameters": {
        "chatId": "-488999349",
        "text": "=Hey You got New Order from {{$node[\"WooCommerce Trigger\"].json[\"billing\"][\"first_name\"]}}\nProduct: {{$node[\"WooCommerce Trigger\"].json[\"line_items\"][0][\"name\"]}}\nCongrats for Earning {{$node[\"WooCommerce Trigger\"].json[\"total\"]}}",
        "additionalFields": {}
      },
      "name": "Telegram Notification",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1,
      "position": [
        2470,
        260
      ],
      "credentials": {
        "telegramApi": "Telegram n8n bot"
      },
      "disabled": true
    },
    {
      "parameters": {
        "value": "={{ new Date(new Date($json.date_created).getTime() + (365*24*60*60*1000)).toISOString() }}",
        "dataPropertyName": "DOE",
        "custom": true,
        "toFormat": "YYYY-MM-DD",
        "options": {
          "toTimezone": "UTC"
        }
      },
      "name": "Date of Expiry",
      "type": "n8n-nodes-base.dateTime",
      "typeVersion": 1,
      "position": [
        1060,
        250
      ]
    },
    {
      "parameters": {
        "functionCode": "let index = 0;\nfor (const data of $node[\"WooCommerce Trigger\"].json[\"meta_data\"]) {\n  items[0].json[`url${index++}`] = data.value.replace(/^(?:https?:\\/\\/)?(?:www\\.)?/i, \"\").split('/')[0];\n}\nreturn items;\n"
      },
      "name": "Function",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        1420,
        250
      ]
    },
    {
      "parameters": {
        "message": "=https://gotify.personalizery.com/",
        "additionalFields": {
          "priority": 10,
          "title": "=New Purchase by {{$node[\"WooCommerce Trigger\"].json[\"billing\"][\"first_name\"]}}"
        }
      },
      "name": "Gotify",
      "type": "n8n-nodes-base.gotify",
      "typeVersion": 1,
      "position": [
        1960,
        250
      ],
      "credentials": {
        "gotifyApi": "Personalizery Purchase"
      }
    }
  ],
  "connections": {
    "Automizy": {
      "main": [
        [
          {
            "node": "Telegram Notification",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "WooCommerce Trigger": {
      "main": [
        [
          {
            "node": "IF Product ID is 12",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "WooCommerce": {
      "main": [
        [
          {
            "node": "Date Of Purchase",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "MySQL": {
      "main": [
        [
          {
            "node": "Gotify",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate New Key": {
      "main": [
        [
          {
            "node": "Function",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF Product ID is 12": {
      "main": [
        [
          {
            "node": "WooCommerce",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "NoOp",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare to Proceed": {
      "main": [
        [
          {
            "node": "MySQL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Date Of Purchase": {
      "main": [
        [
          {
            "node": "Date of Expiry",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Date of Expiry": {
      "main": [
        [
          {
            "node": "Generate New Key",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Function": {
      "main": [
        [
          {
            "node": "Prepare to Proceed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Did you check in WooCommerce if there are for some reason multiple Webhook-Triggers? Because that is the only thing I can think of right now.

Possibly a bug in WooCommerce.

I have created an issue, Let’s see how it goes.

Will update this post too.

Great thanks. But did you check if multiple webhook URLs are set in WooCommerce?
Because if there is only one webhook URL registered but it gets called multiple times it would be a WooCommerce bug. If there are multiple webhook URLs registered it would be an n8n bug.

@jan I’m confused man.

I’m using WooCommerce Trigger Node which uses Consumer Key, Consumer Secret, and URL.

  • But I never created a webhook inside WooCommerce Store.

  • So n8n will create a webhook inside WooCommerce with the credentials provided?

  • Why I’m asking this because. I noticed the word ‘n8n’ inside the webhook tab of WooCommerce. (I removed everything, Yes. Multiple webhook)

Yes exactly. That is how almost all the third-party Trigger-Nodes work. n8n takes automatically care of creating and deleting webhooks in the application if a workflow gets activated or deactivated.

Ah ok, so there were multiple ones. If you now deleted all of them and deactivate and reactivate your workflow it should create a new one. But only one. And then it should again just trigger just once.

What is the possible cause of multiple webhook being created and not getting deleted?

And what are the minimum server requirements you prefer for n8n?
Asking this because, This will affect and create any problem like this?

Update:

n8n is actually creating multiple webhook (duplicate)

Honestly not 100% sure. That should theoretically not happen.

Server specs should not matter here.

There is actually just one duplicate, not two. Only the last two ones have the same webhook-URL. So I guess the first one is for another workflow. n8n creates a webhook for each Trigger-Node you create in n8n.

We have to investigate why this is happening.

1 Like

@jan Issue Solved

Here is my mistake.

  • I set the Workflow to active state which created a new webhook
  • Then I executed the workflow which created one more webhook

This is the main cause of the issue. It’s not related to WooCommerce nor n8n.

Thanks for your time. Everything works great.

1 Like

Thanks a lot for this additional information! Is really helpful.

But would still be an n8n bug as it should no matter what accumulate multiple webhooks. I already created an internal ticket and we will look into it.

1 Like

@mcnaveen do you have a Woocommerce sandbox that I can use for testing? Fixed the issue but have not been able to test it.

1 Like

Sorry for the delay bro. Will send you in Private Message.

Update: Sent bro. @RicardoE105 Please check inbox

We just released [email protected] which should fix the bug.

1 Like

OMG, It was a surprise. Have this Watermelon :watermelon: