fix(core): Make sub-workflows with waits return correct data to parents #13869
+304
−7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Executing sub workflows with
Execute Sub Workflow
s inoptions.waitForSubWorkflow
mode containingWait
nodes or "Human in the Loop"sendAndWait
nodes would make them return wrong data to the parent workflow once execution resumed after the sub workflow resumed fromwaiting
state.This affected at least:
"Wait" nodes using resume modes
webhook
form
specificTime
, if the chosen time is more than 65 seconds awaytimeInterval
, if the chosen interval is longer than 65 seconds"Human in the loop" nodes in
sendAndWait
operation modeor any other nodes that would call
putExecutionToWait
. When parent workflow execution resumed it never received the final output from the sub workflow, and the input toExecute Sub Workflow
node was be "returned" from the execution instead (like whenoptions.waitForSubWorkflow
mode is disabled).This PR fixes this by copying the output from last node of sub workflow into the input of its parent workflow's waiting node, which should be the
Execute Sub Workflow
node. This works well inRun once with all items
mode but I now realized that theRun once with each item
mode behaves differently here and this fix doesn't work for it yet.The issue can be reproduced with these workflows
Simple_parent.json
Simple_Wait_Webhook_child.json
Note that the wait has to be longer than 65 seconds, but webhook, form and one of the many
sendAndWait
nodes can be used instead.Related Linear tickets, Github issues, and Community forum posts
https://linear.app/n8n/issue/ADO-3297/community-issue-calling-a-sub-workflow-with-a-wait-by-webhook-node
Fixes #13135
Review / Merge checklist
release/backport
(if the PR is an urgent fix that needs to be backported)