Subworkflow execution shows that it returned data but parent workflow doesn't receive it

Describe the problem/error/question

Subworkflow is called and execution history indicates success and shows a output data.

Parent workflow indicates that the subworkflow did not return data (no item in execution view)

This seems to be happening occasionally, but not consistently What troubleshooting steps can I explore?

Information on your n8n setup

Debug info

core

  • n8nVersion: 1.116.2
  • platform: docker (self-hosted)
  • nodeJsVersion: 22.18.0
  • nodeEnv: production
  • database: sqlite
  • executionMode: regular
  • concurrency: -1

Try toggling on the option to make the main workflow wait(refer to image).

Also make sure the last node in your sub-workflow output data at all times.

Thank you. I thought that was the default but I have explicitly set that now.

        "mode": "each",
        "options": {
          "waitForSubWorkflow": true
        }

Yes, the subworkflow is returning data even when this condition arises.

I think the issue might be in the last node of the subworkflow, the Code node specifically in its mode and how it handles the input items,

There are three inputs to that node, and from the attached image, it seems that only the middle path is being executed.

I don’t have the full picture of your logic,
but to make sure you’re getting the data you actually expect,
try adding a Set node after the last node (Code node) in the subworkflow, Then check whether it returns the values you expect or nothing..

If it helps:

I think I know the issue, it’s a behavioral logic problem with how multi-branch node inputs work.

Let me explain using a simple workflow,
This workflow is a multi-branch workflow:


Node 3 takes two branches as input, so the execution flow will be:

  • First: 1 → 3
  • Second: 2 → 3

As a result, node 3 receives two inputs and outputs two items (two branches).
This can be confusing, because these aren’t just two normal items, they’re actually one item from each branch.

Now, when you execute this same logic inside a subworkflow:

You’ll notice that you only get one item! What the :smiley:

Actually, the item you get here is from the last branch executed in the subworkflow.

I’m not sure why it’s engineered or designed this way, but that’s how it currently works.

So, what’s the solution?
The lazy/easy fix is to add a “Nothing” loop :smiley: like this:

This ensures that all items (branches) are looped over.
Now, if we execute the subworkflow again:

We’ll get all the items from all branches.

However IMO the best approach is to avoid using branches altogether,
If you need to branch, do it using the Merge node instead, like this:

As you can see, we get the same two items:

Hope this explains everything!

2 Likes

I’ll need to read that a few more times before it sinks in, but I think I got main point about needing a merge.

I don’t even need the output of the lower “TODO” nodes but I wasn’t sure if I could let them “dangle” so I tied them back in. I’ve added a merge node now prior to the code node.

1 Like