Merge PassThrough to wait for second input

Introduction:

Merge has many modes, and passthrough is one of them. The PassThrough will wait untill the workflow is past the second input before passing through the first input. This is great for controlling execution order. But bad for preventing a branch from operation which is a great application of the merge node.

The idea is:

To add a “Wait for second input” option so that the node will not pass through input 1 until at least one item from input 2 has been received. Turning it into a gate.

My use case:

Input 1 contains important data, input two is a bool a throwback from a switch near the end of in the workflow. If the hypothetical workflow ran all the way to the end and was true it could kick back an event and trigger an an extra leg. If false it would do something else… end in a different way.

I think it would be beneficial to add this because:

Adds more capability when creating advanced flows

Are you willing to work on this?

Yes, but I need some training on the source code before I can consider contributing.

Hi @roofboard

The merge node already has a wait option. Is this what you are after?

@BramKnuever Thanks for the replay.

Actually I did further testing, this may be a bug. I am working up a sample workflow and will post back here with the example. From what I can tell wait is not waiting for an item to be dropped in the workflow from what I can tell wait is only waiting for the execution flow to move past both legs.

Then it outputs data even if there are no items in the number 1 or number 2 items array as pictured above.

Hi @roofboard

I’ve used it in the past to make sure some conditions were met on one of the 2 input and then passing that to this merge node.
So yes, it does accept any input but there should be something there on both inputs for it to trigger.

Ill look at you example when you post it. Feel free to tag me in it, to make sure I get notified.

@anon87652862 I believe I am seeing this as well. To be more specific, I’m seeing inconsistent behavior from the Merge Node Wait for Both Inputs To Arrive function. In all but one case I’ve seen so far the Wait for Both Inputs to Arrive is working, however, in one case it is not working and when the first input is received the workflow proceeds.

In this screenshot you can see that input 2 has not been received but workflow proceeds past the merge anyway.

It looks like this may be due to using Choose Branch as well. Since I am set to wait for both inputs, but only input 1 is required then the workflow proceeds.

I am only using Merge in this way in order to pass multiple items through If and Switch nodes. If there is a better way to do this then I won’t need to use Merge in this way.

Here’s an example of the inconsistency I mentioned where an identically configured Merge node exhibit different behavior - it waits for all inputs before proceeding.


Further testing suggests there is a bug where Wait for Both Inputs and Choose Branch behaves as expected if Output is set to Input 2 Data

Another Merge related issue/question:

Screenshot 2023-05-14 at 22.26.33

This merge append continues without Input 2:

Hi @ryanflomenco

Please create a new topic :wink:

Can confirm. A bug is still there.
For now I will use workaround, using Output of Item 2

From what I see does it look like that the following PR could solve that problem:

It will be released with n8n v1 end of June.

Thanks @jan!