Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge Node runs without both inputs #7775

Closed
Panoplos opened this issue Nov 22, 2023 · 8 comments
Closed

Merge Node runs without both inputs #7775

Panoplos opened this issue Nov 22, 2023 · 8 comments
Labels

Comments

@Panoplos
Copy link

Describe the bug

The "Merge Node" is executing without having received data from both inputs.

image
image

To Reproduce
Steps to reproduce the behavior:

Recreate flow in the attached diagram.

Expected behavior
The Merge Node should not execute until it has received both inputs.

Environment (please complete the following information):

  • OS: Ubuntu Linux 22.04
  • n8n Version: 1.16.0
  • Node.js Version: 18
  • Database system: Postgres 14.8
  • Operation mode: main

Additional context
Add any other context about the problem here.

@janober
Copy link
Member

janober commented Nov 22, 2023

Yes, that is expected and correct behavior.

Merge3 waits until both connected nodes have been executed (and no node execution is outstanding). If there is no data on one of the inputs, it continues to process with the data it received.

HTTP Request3 executes correctly 2x as it receives data 2x (it has an incoming connection from 2 different nodes). The "Execute Once" option is not about executing only once if it gets called multiple times, it is about executing only the first item for every call it receives. So if you call it once with 5 items and once with 3 it would normally make 8 requests. With "Execute Once" activated will it only run 2x. 1x for the first item of the 5 and 1x for the first item of the 3.

I hope that makes sense.

@Panoplos
Copy link
Author

This is confusing. In other run scenarios, it behaves as I expected. Below you can see Merge1 does not output anything, yet it has received data from a single input.
image

@Panoplos
Copy link
Author

BTW, as a user of the system, we find that with many of the built-in nodes, they do not have options for augmenting the input, just drops and outputs its own output, like Read PDF, OpenAI, and HTTP Request nodes, so we have to create this whole convoluted merge flow...which also impacts conditional branch execution like this. A visitor pattern would do wonders for this DX.

Also, when binary data is present, all nodes that need access to it should allow access with use of "Expression", as most just require some hardcoded index into the binary data. In our case, we have multiple attachments that we need to select from, and I had to the following to set the attachment into a new binary entry to allow for handling the hard-coded indexer requirement.
image

@janober
Copy link
Member

janober commented Nov 22, 2023

Merge1 is different as it has the Mode "chooseBranch" set which behaves differently. If it is set to the first input (as I assume in your case) and there is no data on that input, then the node does not run. As the chosen input did not provide any data.

Agree, that is really something we have to tackle at some point. We just have to think about properly how exactly it should work and behave.

Sorry, do not understand what you mean with binary data and expressions.

@Panoplos
Copy link
Author

Panoplos commented Nov 22, 2023

How do you suggest I keep the flow from executing in this case?

For the binary data issue, see below. This is an HTTP Request node. When I want to send attachment data, I have to provide the hard-coded path to the desired attachment. (My workaround was that I converted the attachment to JSON (binary format), then back to a binary object with a name I choose. Then I can just use this single path with variable content. The Input Data Field Name should allow me to use an Expression to set it.

image

maspio added a commit that referenced this issue Nov 23, 2023
…ds (#7782)

Github issue / Community forum post (link here to close automatically):
#7775
netroy pushed a commit that referenced this issue Nov 29, 2023
…ds (#7782)

Github issue / Community forum post (link here to close automatically):
#7775
@janober
Copy link
Member

janober commented Nov 30, 2023

Fix got released with n8n@1.18.1

@Joffcom
Copy link
Member

Joffcom commented Dec 4, 2023

Good news, This should now be resolved. If it is still an issue let me know and I will get this opened again.

@janober
Copy link
Member

janober commented Dec 4, 2023

To be clear. What has been resolved is not the Merge-Node behavior. It is the issue that for some reason, the expressions were disabled for the Input Data Field.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants