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

fix(core): Make sub-workflows with waits return correct data to parents #13869

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Cadiac
Copy link
Contributor

@Cadiac Cadiac commented Mar 12, 2025

Summary

Executing sub workflows with Execute Sub Workflows in options.waitForSubWorkflow mode containing Wait 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 from waiting state.

This affected at least:

"Wait" nodes using resume modes

  • webhook
  • form
  • specificTime, if the chosen time is more than 65 seconds away
  • timeInterval, if the chosen interval is longer than 65 seconds

"Human in the loop" nodes in sendAndWait operation mode

  • Discord
  • Gmail
  • Google Chat
  • Microsoft Outlook
  • Microsoft Teams
  • Send Email
  • Slack
  • Telegram
  • Whatsapp Business Cloud

or 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 to Execute Sub Workflow node was be "returned" from the execution instead (like when options.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 in Run once with all items mode but I now realized that the Run 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

  • PR title and summary are descriptive. (conventions)
  • Docs updated or follow-up ticket created.
  • Tests included.
  • PR Labeled with release/backport (if the PR is an urgent fix that needs to be backported)

@n8n-assistant n8n-assistant bot added core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team labels Mar 12, 2025
Copy link

codecov bot commented Mar 12, 2025

Codecov Report

Attention: Patch coverage is 70.58824% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
packages/cli/src/wait-tracker.ts 70.58% 4 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team
Projects
None yet
1 participant