Description:
My workflow setup is as follows:
A main workflow triggers a sub-workflow that encapsulates fixed operations.
The sub-workflow’s output should be returned to the main workflow’s execution node for downstream tasks.
Expected Behavior:
The sub-workflow final node’s output is correctly passed to the main workflow as the outputs of execution node.
Issue:
When the sub-workflow contains only simple nodes (e.g., code nodes), everything works as expected. When the sub-workflow includes a wait node (configured to use a webhook for third-party interaction), the output returned to the main workflow is the wait node’s input instead of the final node’s output.
Root Cause Investigation:
By reviewing the n8n source code, I traced the logic in workflow-execute-additional-data.ts, specifically the startExecution method:
// subworkflow either finished, or is in status waiting due to a wait node, both cases are considered successes here
if (data.finished === true || data.status === ‘waiting’) {
// Workflow did finish successfully
activeExecutions.finalizeExecution(executionId, data);
const returnData = WorkflowHelpers.getDataLastExecutedNodeData(data);
return {
executionId,
data: returnData!.data!.main,
waitTill: data.waitTill,
};
}
activeExecutions.finalizeExecution(executionId, data);
This logic treats a sub-workflow in waiting state (e.g., after triggering a wait node) as “successfully completed” and returns the wait node’s input data. However:
The sub-workflow is not truly finished — it resumes after the webhook callback and executes the final node.
The final node’s output is never returned to the main workflow.
Additional Context:
The “Wait For Sub-Workflow Completion” option is enabled in the main workflow (default behavior).
This option controls the doNotWaitToFinish flag in executeWorkflow method. When doNotWaitToFinish: true, the sub-workflow directly returns [null] at the beginning of sub execution, which is unrelated to this issue.
if (options.doNotWaitToFinish) {
return { executionId, data: [null] };
}
Questions for the Community:
Why is the waiting state intentionally treated as “successful completion” instead of waiting for the sub-workflow to fully finish? The comment in the code explicitly states this is intentional, but it conflicts with the expectation that the main workflow should receive the final output of the sub-workflow.
I attempted to modify the code by removing the || data.status === ‘waiting’ condition. The sub-workflow then completed normally, but the main workflow’s execution node threw a generic error: “An error occurred”. What internal mechanisms might cause this?
Is there a supported way to ensure the main workflow receives the sub-workflow’s final output (not the wait node’s input) when using webhook-based wait nodes? This seems like a common integration scenario.
Information on your n8n setup
- n8n version:1.82.3
- Database (default: SQLite):
- n8n EXECUTIONS_PROCESS setting (default: own, main):
- Running n8n via (Docker, npm, n8n cloud, desktop app):
- Operating system: