I can't seems to understand were my workflow fail

Hello, I just discovered n8n and I’m already a fan. My first WF was easy to setup but the second one that looks a lot like the first breaks without error. If anyone got an idea of the reason that would be great !

My WF is supposed to check for me if some manga chapter is out on a site and if it is, send me a message on Disord.

I have a very simple postgres database with one table that keep the last chapter number of each manga followed.

I have inserted some logging instructions in the function nodes. It seems that the sub-WF is weirdly partially executed.

My main WF will get the list of website to query, make the requests and pass the HTMLs to the sublow.
The Subflow will parse the HTML check if the chapter is more recent than the one in the DB, if yes send a message on discord and log a string in the terminal else directly log the string.

Main:

{
  "nodes": [
    {
      "parameters": {
        "triggerTimes": {
          "item": [
            {
              "mode": "everyX",
              "value": 1,
              "unit": "minutes"
            }
          ]
        }
      },
      "name": "Cron",
      "type": "n8n-nodes-base.cron",
      "typeVersion": 1,
      "position": [
        450,
        450
      ]
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "SELECT id, name, source, site, last_chapter\nFROM mangas"
      },
      "name": "Postgres",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 1,
      "position": [
        650,
        450
      ],
      "credentials": {
        "postgres": "n8n"
      }
    },
    {
      "parameters": {
        "functionCode": "console.log('Postgres result:');\nconsole.table(item);\nreturn item;"
      },
      "name": "FunctionItem",
      "type": "n8n-nodes-base.functionItem",
      "typeVersion": 1,
      "position": [
        850,
        450
      ]
    },
    {
      "parameters": {
        "workflowId": "3"
      },
      "name": "Execute Workflow",
      "type": "n8n-nodes-base.executeWorkflow",
      "typeVersion": 1,
      "position": [
        1240,
        450
      ]
    },
    {
      "parameters": {
        "url": "={{$node[\"FunctionItem\"].json[\"source\"]}}",
        "responseFormat": "string",
        "options": {}
      },
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        1050,
        450
      ]
    }
  ],
  "connections": {
    "Cron": {
      "main": [
        [
          {
            "node": "Postgres",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Postgres": {
      "main": [
        [
          {
            "node": "FunctionItem",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "FunctionItem": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "Execute Workflow",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Sub workflow:

{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        270,
        360
      ]
    },
    {
      "parameters": {
        "functionCode": "return $item(0).$node['Start'].data;"
      },
      "name": "FunctionItem",
      "type": "n8n-nodes-base.functionItem",
      "typeVersion": 1,
      "position": [
        470,
        360
      ]
    },
    {
      "parameters": {
        "extractionValues": {
          "values": [
            {
              "key": "chapter",
              "cssSelector": "div.bixbox:nth-child(3) > ul:nth-child(2) > li:nth-child(1) > span:nth-child(1) > a:nth-child(1)"
            },
            {
              "key": "link",
              "cssSelector": "div.bixbox:nth-child(3) > ul:nth-child(2) > li:nth-child(1) > span:nth-child(1) > a:nth-child(1)",
              "returnValue": "attribute",
              "attribute": "href"
            }
          ]
        },
        "options": {}
      },
      "name": "HTML Extract",
      "type": "n8n-nodes-base.htmlExtract",
      "typeVersion": 1,
      "position": [
        670,
        360
      ]
    },
    {
      "parameters": {
        "functionCode": "console.log(\"TEST\");\nconsole.table(items[0]);\nitems[0].json.chapter = parseInt(items[0].json.chapter.split(\" \")[1]);\nconsole.log(items[0].json.link);\nconsole.log(items[0].json.chapter );\nreturn items;"
      },
      "name": "Function",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        870,
        360
      ]
    },
    {
      "parameters": {
        "conditions": {
          "number": [
            {
              "value1": "={{$node[\"Function\"].data[\"chapter\"]}}",
              "operation": "larger",
              "value2": "={{$node[\"Start\"].data[\"last_chapter\"]}}"
            }
          ]
        }
      },
      "name": "IF",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        1070,
        360
      ]
    },
    {
      "parameters": {
        "webhookUri": "https://discordapp.com/api/webhooks/758125700171169832/qyoIn_RgBg3z3WFYkgHsfvfvAB6rF_BXKeApRfMC6jJgNVxlkkMXHWoHWnMlHwaM-VI_",
        "text": "=<@&758021294896709643> {{$node[\"Start\"].data[\"name\"]}} chapter {{$node[\"Function\"].data[\"chapter\"]}} released at {{$node[\"Function\"].data[\"link\"]}}!"
      },
      "name": "Discord",
      "type": "n8n-nodes-base.discord",
      "typeVersion": 1,
      "position": [
        1240,
        220
      ]
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "=UPDATE mangas\nSET last_chapter = {{$node[\"Function\"].data[\"chapter\"]}}\nWHERE name = '{{$node[\"Start\"].data[\"name\"]}}'"
      },
      "name": "Postgres",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 1,
      "position": [
        1420,
        220
      ],
      "credentials": {
        "postgres": "n8n"
      }
    },
    {
      "parameters": {
        "functionCode": "console.log(\"ASURA2 END\");\nreturn true;"
      },
      "name": "FunctionItem1",
      "type": "n8n-nodes-base.functionItem",
      "typeVersion": 1,
      "position": [
        1590,
        380
      ]
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "FunctionItem",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "FunctionItem": {
      "main": [
        [
          {
            "node": "HTML Extract",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTML Extract": {
      "main": [
        [
          {
            "node": "Function",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Function": {
      "main": [
        [
          {
            "node": "IF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF": {
      "main": [
        [
          {
            "node": "Discord",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "FunctionItem1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Discord": {
      "main": [
        [
          {
            "node": "Postgres",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Postgres": {
      "main": [
        [
          {
            "node": "FunctionItem1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

The database used:

create table mangas
(
    id           serial  not null
        constraint mangas_pk
            primary key,
    name         text    not null,
    source       text    not null,
    last_chapter integer not null,
    site         text
);

alter table mangas
    owner to driky;

create unique index mangas_id_uindex
    on mangas (id);

INSERT INTO public.mangas (id, name, source, last_chapter, site) VALUES (1, 'Skeleton Soldier Couldn’t Protect the Dungeon', 'https://asurascans.com/manga/skeleton-soldier-couldnt-protect-the-dungeon/', 101, 'asura');
INSERT INTO public.mangas (id, name, source, last_chapter, site) VALUES (34, 'A Returner’s Magic Should Be Special', 'https://asurascans.com/manga/a-returners-magic-should-be-special/', 121, 'asura');

The logs:

n8n_1       | Postgres result:
n8n_1       | β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
n8n_1       | β”‚   (index)    β”‚                               Values                                β”‚
n8n_1       | β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
n8n_1       | β”‚      id      β”‚                                      1                                       β”‚
n8n_1       | β”‚     name     β”‚               'Skeleton Soldier Couldn’t Protect the Dungeon'                β”‚
n8n_1       | β”‚    source    β”‚ 'https://asurascans.com/manga/skeleton-soldier-couldnt-protect-the-dungeon/' β”‚
n8n_1       | β”‚     site     β”‚                                   'asura'                                    β”‚
n8n_1       | β”‚ last_chapter β”‚                                     101                                      β”‚
n8n_1       | β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
n8n_1       | Postgres result:
n8n_1       | β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
n8n_1       | β”‚   (index)    β”‚                               Values                                β”‚
n8n_1       | β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
n8n_1       | β”‚      id      β”‚                                 34                                  β”‚
n8n_1       | β”‚     name     β”‚               'A Returner’s Magic Should Be Special'                β”‚
n8n_1       | β”‚    source    β”‚ 'https://asurascans.com/manga/a-returners-magic-should-be-special/' β”‚
n8n_1       | β”‚     site     β”‚                               'asura'                               β”‚
n8n_1       | β”‚ last_chapter β”‚                                 121                                 β”‚
n8n_1       | β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
n8n_1       | TEST
n8n_1       | β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
n8n_1       | β”‚ (index) β”‚    chapter    β”‚                                        link                                        β”‚
n8n_1       | β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
n8n_1       | β”‚  json   β”‚ 'Chapter 102' β”‚ 'https://asurascans.com/skeleton-soldier-couldnt-protect-the-dungeon-chapter-102/' β”‚
n8n_1       | β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
n8n_1       | https://asurascans.com/skeleton-soldier-couldnt-protect-the-dungeon-chapter-102/
n8n_1       | 102
n8n_1       | ASURA2 END
n8n_1       | ASURA2 END

Hey @Driky!

Welcome to the n8n community!

If you’re running in production, the output of the nodes is not displayed. You can check the executions and go to the state where it failed and debug the error. To do that click on β€˜Executions’.

You can then click on the β€˜Open Past Execution’ button.

Also, is there a particular reason that you have two separate workflows here? You can build this as a single workflow. If you’re reusing the sub-workflow then it makes sense.

I haven’t tested your workflow yet, I will try to look more into it.

Let me know if you have any other questions!

1 Like

Thank you for the welcome and the time you took to answer my question.

Regarding the sub WF I will have different SW that can be switched to depending on which site host the manga.

But for development sake I inlined everything and it allowed me to find the problem.

Somehow during development I switched a FunctionItem for a Function, which obviously broke everything =P

Since I was not running in production the Execution menu didn’t help but it’s still nice to learn that it exist :wink:

If you have the workflows set to save failed executions you should be able to also see the error in past-executions of sub-workflows as @harshil1712 explained.

I just discovered that you can also save manually executed worflow, which was the case I was in when developing.

Thank you @jan and @harshil1712 for your help :wink:

1 Like

Ah yes sorry my mistake. I should also have mentioned that!

Glad to hear that it works now.