Both nodes after IF executed

Describe the issue/error/question

Sometimes, both nodes after an IF node are executed, although no data flows though the inactive one. See the following picture:
grafik
The Code node is not set up to always output data, neither is the IF.
Edit: I thought the problem could be solved by changing the code from execute per item to execute once. However, if I only execute the “Fetch today’s events” node (not the whole workflow), everything works fine. If I execute everything, there’s this strange behavior.
This is the Input the node gets:

{
  "json": {},
  "pairedItem": {
    "item": 0
  }
}

What is the error message (if any)?

Unfortunately N8N does not tell me what is wrong.

Please share the workflow

Only sharing the part of the workflow.

Share the output returned by the last node

The workflow stops (for me there’s no reason why)

Information on your n8n setup

  • **n8n version:**0.209.1
  • **Database you’re using (default: SQLite):**MariaDB
  • **Running n8n with the execution process [own(default), main]:**default I think
  • **Running n8n via [Docker, npm, n8n.cloud, desktop app]:**Docker

Hey @ericfischereu,

Welcome to the community :tada:

Are you able to share more of the workflow so I can see what else is running? Normally something like this would happen if there was a merge node being used somewhere.

Thanks for the fast reply. Here’s a bigger snippet:

That looks ok, What is happening in Fetch Todays Events?

Just to note: I had this phenomena without called workflows, too.
However, the Fetch makes a CalDAV request (scrapegoat, Code node), fetches the events for today and adds some information from the ICS for the event. After that, I use a Code node to sort the events. There is a merge by index node in this workflow.

I had the same problem in another place again, maybe it’s not only related to IFs but to the Code nodes:

grafik

Merge tasks list… is returning an empty array, so (according to the docs) the execution should stop. Since the line isn’t green I assume the system could know that there’s no item.

Maybe here’s a hint what’s wrong. I’m on version 0.217.2 right now.

The failing code node is connected to the false branch of an IF node, which has no items. However, the failing code node triggers with the data from the TRUE node.

This does not happen, if I put any node (in my case the NoOp node) between the IF and the code node.

This feels like potentially quite a bad bug that we should definitely look into — many thanks for reporting it, Eric.

To help us reproduce it and investigate further, would you mind sending us your workflow using the following steps?

  1. Execute the workflow and pin all the nodes that fetch data (e.g. the HTTP node)
  2. Replace the trigger with a function node that outputs the data that is passed into this workflow
  3. Download the workflow and send us the json file

I’ll send you my email in a DM so that you don’t need to post the workflow publicly.

Thanks!

So the behaviour you’re seeing seems to be down to the current behaviour of the ‘merge’ node.

When a merge node has input on only one branch, it goes back to try to execute the nodes on the other branch so that it gets input on both branches. In the process of going back it gets to your node that has 2 input connectors, so has to choose one. In this case it chooses wrong.

This is behaviour that we will change in an upcoming version of n8n, so that this problem doesn’t occur. We’ve actually made the change already, but are waiting to package it up with other big changes to minimise disruption.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.