Rest executions doesn't detect all waiting workflows

I have a workflow setup using localhost:5678/rest/executions that prevents the flow from running when other flows are in “waiting” status. However however not all wait flows are being detected, therefore there are instances the flow starts resulting in multiple instances of the flow running.

n8n Version: 0.151.0
Video of issue https://drive.google.com/file/d/105-NTONt_fRZycr_BIMXSg2nspwzVsmH/view?usp=sharing



{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        200,
        640
      ]
    },
    {
      "parameters": {
        "fieldToSplitOut": "data.results",
        "options": {}
      },
      "name": "Item Lists",
      "type": "n8n-nodes-base.itemLists",
      "typeVersion": 1,
      "position": [
        640,
        640
      ]
    },
    {
      "parameters": {
        "authentication": "basicAuth",
        "url": "http://localhost:5678/rest/executions",
        "options": {},
        "queryParametersUi": {
          "parameter": [
            {
              "name": "filter",
              "value": "{}"
            },
            {
              "name": "limit",
              "value": "30"
            }
          ]
        }
      },
      "name": "HTTP Request2",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        420,
        640
      ],
      "credentials": {
        "httpBasicAuth": {
          "id": "22",
          "name": "n8n Incluzion"
        }
      }
    },
    {
      "parameters": {
        "functionCode": "return [{\n  json: {\n    waiting_workflows: items.filter(e => e.json.finished === false && e.json.waitTill).length\n  }\n}]"
      },
      "name": "Function1",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        860,
        640
      ]
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "HTTP Request2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Item Lists": {
      "main": [
        [
          {
            "node": "Function1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request2": {
      "main": [
        [
          {
            "node": "Item Lists",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Hi @datdudejibril, seeing this is an undocumented API used by the UI, the best approach to this would be to do some discovery work yourself here. Inspect the network requests made by the UI, take a look how certain execution states are represented in the UI and how they look in the REST API.

If the UI can detect the correct state, you should be able to recreate the filtering used in the Function node as well. If you need help with filtering a specific execution, could you share your example data returned by the REST API endpoints you are using?

Thx a lot!

1 Like

Thanks. This helps!

After getting correct api endpoint I can see that in the browser is returns the correct data I need. I also found out that the Http node wasn’t configured correctly. No matter what parameters I entered for the endpoint it always returned all the data instead of filtered results. But now that’s working as well.


1 Like

Awesome, glad to hear you figured it out and thanks so much for confirming!