Parallel Task Synchronization and Wait-For-All Loop - n8n Workflow

Execute multiple asynchronous sub-workflows in parallel using n8n webhooks and synchronously wait for all tasks to complete using a robust n8n node loop pattern. Ideal for long-running processes.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Automation developers needing to execute long-running tasks concurrently within n8n.
Users looking for advanced n8n templates for robust flow control and synchronization.
Technical teams building reliable, scalable backend processes with n8n.
Anyone needing to implement a "wait for all" logic across separate n8n workflow executions.

Overview

This advanced n8n workflow demonstrates a critical design pattern for managing asynchronous, parallel execution of tasks. When you have a list of items that require significant processing time (e.g., generating reports, massive data transformation), running them sequentially is inefficient. This specialized n8n workflow pattern utilizes a parent-child relationship where the parent simultaneously kicks off multiple independent sub-workflows (via webhook calls) and then enters a sophisticated waiting loop, anchored by the Webhook Callback Wait n8n node. This ensures the parent execution only proceeds after receiving confirmation (via resume webhook callbacks) from all initiated sub-workflows. This n8n workflow template is essential for building highly concurrent and resilient automation systems within n8n.

How it Works


  1. Trigger and Initialization: The main n8n workflow starts via a manual n8n trigger. It uses a Code n8n node to simulate multiple data items requiring parallel processing. A Set n8n node initializes the crucial state variable finishedSet (an empty array) to track completed tasks.

  2. Parallel Dispatch: The Split In Batches n8n node iterates over the simulated items. For each item, an HTTP Request n8n node calls the webhook endpoint of the separate sub-workflow execution, passing the item ID and, critically, the parent workflow's unique resume URL ($execution.resumeUrl) as a callback header.

  3. Sub-Workflow Execution: The child n8n workflow (which runs separately) receives the request via its Webhook n8n trigger, immediately responds to prevent the parent's HTTP Request from blocking, and then simulates the required processing time.

  4. Callback and Resume: Once the sub-task finishes, it uses an HTTP Request n8n node to hit the parent workflow's specific resume webhook URL (obtained from the callbackurl header), signaling its completion and passing the finished item ID.

  5. Synchronization Loop (Parent): The parent n8n workflow flow is managed by a loop: It checks the If All Finished condition. If synchronization is not complete, it pauses at the designated Webhook Callback Wait n8n node. Upon being resumed by a sub-workflow callback, a Code n8n node updates the finishedSet array with the newly finished item ID. The process then loops back to the If All Finished node to re-check the count.

  6. Completion: Only when the number of items in finishedSet matches the total number of items originally dispatched does the parent n8n workflow continue to the final step.

Installation Guide


  1. Import: Import this entire n8n workflow JSON into your n8n instance.

  2. Separate the Sub-Workflow: The nodes intended for the child execution (starting with the Webhook node labeled 'Webhook' at path parallel-subworkflow-target and the following nodes) must be copied and pasted into a separate, new n8n workflow. Activate this sub-workflow.

  3. Environment Setup: For the parent n8n workflow to initiate the children, you must configure the WEBHOOK_URL environment variable in your n8n instance configuration. This URL must be the base URL where the child workflow's public webhook endpoint can be reached. If self-hosting, ensure this points to the correct internal service or domain.

  4. Activation: Activate both the parent and child n8n workflow templates to ensure the webhook endpoints are live.

  5. Execution: Run the parent n8n workflow manually to observe the parallel dispatch and synchronous waiting pattern.

Node Details

Manual Trigger: When clicking ‘Test workflow’. Serves as the initial n8n trigger to start the parent execution.
Code Node: Simulate Multi-Item for Parallel Processing. Generates an array of three items (requestIds) to simulate the tasks requiring parallel execution.
Split In Batches Node: Loop Over Items. Manages the iteration, ensuring the HTTP Request n8n node is executed for every item.
Set Node: Initialize finishedSet. Creates the initial state variable finishedSet as an empty array, crucial for tracking synchronization status in the n8n workflow.
HTTP Request Node: Start Sub-Workflow via Webhook. This n8n node initiates the parallel sub-workflow executions. Key Configuration: Passes the parent's unique $execution.resumeUrl in the callbackurl header.
If Node: If All Finished. This core synchronization n8n node checks if the count of finished items equals the count of original items, controlling whether the flow pauses or proceeds.
Wait Node: Webhook Callback Wait. Pauses the parent n8n workflow execution until a specific external webhook call hits its unique resume endpoint. This acts as the synchronization barrier.
Code Node: Update finishedSet. Upon resumption, this n8n node uses JavaScript to safely update and append the newly finished finishedItemId from the webhook payload to the state tracked in the finishedSet array.
Webhook Node (Sub-Workflow): Acts as the external n8n trigger (parallel-subworkflow-target) for the parallel task execution instances.
HTTP Request Node (Sub-Workflow): Call Resume on Parent Workflow. Executes the crucial callback by hitting the parent workflow's resume URL. It uses retry settings (retryOnFail: true, waitBetweenTries: 3000ms) to mitigate potential race conditions if multiple sub-tasks finish simultaneously and try to resume the parent n8n workflow.

Related n8n Workflows

Free

Nodes: 11 Nodes
Updated: December 26 2025
View all
Created by
Hubschrauber
Hubschrauber

Software developer specializing in "back-end plumbing" to connect and sync data between large corporate systems, enabling application distribution/migration, scaling, and containerization. Using n8n for various orchestration tasks both at home and "on the job."

Featured*