I am stuck because of the Compare Node "Always Output Data" issue

Describe the problem/error/question

I am making a workflow that compares two datasets to update a database. This all runs happens on Supabase. For this I am using the “Compare” node and comparing by a unique code. Input A would be the previous item set, Input B would be the current item set. If an item is in A only then the row should be deleted, if it is in B only a row should be created and if it is in both (here I only use same, as it would never be different), the row should be updated. Now the issue is that very rarely there will be a delete or create execution, but I would still like to run it every time to have a more reliable ouput. This means that usually there will be no items going through the “in A only” and “in B only” branches. But I want all processes to finish and then to execute the next workflow. For this I use a “Merge” node, with 3 inputs, set to “wait for all inputs” before the “Execute Workflow” node. However if no items go down the branches, there is no input for the merge node and the workflow hangs. I tried using the “Always Output Data” of the “Compare” node, but it annoyingly only outputs one empty item to the A branch, which leaves the B branch empty still. Is there a simple fix to this that I am overlooking or should I scrap the idea and come up with a different approach? I am still quite new to n8n so I might be missing something obvious.

Please share your workflow

Share the output returned by the last node

The output would typically be just the “update row” node passing the items, which means that only one input of the “merge” node will arrive.

Information on your n8n setup

  • n8n version: 1.99.1
  • Database (default: SQLite): unchanged
  • n8n EXECUTIONS_PROCESS setting (default: own, main): unchanged
  • Running n8n via (Docker, npm, n8n cloud, desktop app): VPS
  • Operating system: Windows 10

I can’t make sense of it. Given the Merge node waits for all inputs, it will only be ever executed if the compare node outputs all of its possible options at the same time - Only A, Only B and Same, which will probably never happen.

I don’t know how to make it simple and straight forward. The only way I was able to get close to what you want it to be is with this monstrosity:

Basically this involves re-implementing (sort of) of the Compare Datasets node with Code node so that the output always produced for all three branches. Then each branch is checked for emptiness. If not empty - it is sent to the database action and if is empty - sent directly to the merge, where it will wait for all other branches to go through the same process.

If I saw this in production, I would probably make somebody pay, so, please see if you can come up with something easier.

As a contributor, can you share me what is going on with his code? I’m really confused and cannot translate it to my own n8n:(

Hey @cutecatcode, sorry, went to sleep after sending the message last night.

My understanding is that the issue that Filip is having is as follows:

  • there are two sets of data coming to compare datasets node
  • compare datasets node can output any permutation of outputs - 1 or 2 or all 3 of: Only in A, Same, Only in B.
  • Each output triggers a separate database action
  • All (1 or 2 or 3) of database actions need to finish before proceeding with calling another workflow.
  • Issue is that the Merge node with wait for all inputs waits forever if not all 3 outputs are produced by the compare data sets node (and consequently the database action), otherwise not all database actions are finished before the merge is finished and the workflow proceeds with calling the next workflow.
1 Like

Hey jabbson, I was playing around and managed to find a somewhat decent solution yesterday. Instead I just used the Append option, which waits for all inputs anyways and made it execute once. I think it would work but I will do further testing to ensure it always goes through to second workflow.

Ahhh… I get it. Thanks for explaining this