Skip to main content

WG Wait

Waits for the specified Wait Group to finish, ensuring all the parallel branches associated with it have been completed. The Wait Group is considered complete when the counter, initially set by the WG Add node, decrements to zero due to subsequent executions of the WG Done node for a given ID.

How It Works

  1. The node retrieves the Wait Group ID from the input variable
  2. The wait group is looked up in the global wait groups map using the ID
  3. The node calls the sync.WaitGroup's Wait() method, which blocks execution
  4. The thread is blocked until the internal counter reaches 0 (all WG Done calls complete)
  5. Once unblocked, the wait group is deleted from the global map
  6. If deletion succeeds, the flow continues to the next node
  7. If the wait group was already deleted, the error is silently ignored (allows multiple Wait nodes)
  8. The message passes through unchanged

Requirements

  • A valid Wait Group ID must be provided (from WG Create node)
  • The wait group must exist at the time Wait is called
  • WG Add must have been called to set the expected number of completions
  • All parallel branches must eventually call WG Done to unblock the wait

Error Handling

Error CodeDescriptionCause
Core.WaitGroup.Wait.ErrOnCreateConfig parse errorInvalid node configuration during creation
Core.WaitGroup.Wait.ErrOnMessageMessage parse errorInvalid message format received
Core.WaitGroup.Wait.ErrWaitGroup ID not foundThe specified Wait Group ID doesn't exist

Common Properties

  • Name - The custom name of the node.
  • Version - The version of the plugin.
  • Color - The custom color of the node.
  • Delay Before (sec) - Waits in seconds before executing the node.
  • Delay After (sec) - Waits in seconds after executing node.
  • Continue On Error - Automation will continue regardless of any error. The default value is false.
info

if ContinueOnError property is true, no error is caught when the project is executed even if Catch node is used.

Input

  • Wait Group ID - Unique identifier of the Wait Group you want to wait for to complete.

Usage Examples

Example 1: Wait for All Parallel Branches

WG Create → msg.wgID
└─ WG Add (wgID, Delta: 3)
└─ Fork into 3 branches:
├─ Branch 1 → WG Done (wgID)
├─ Branch 2 → WG Done (wgID)
└─ Branch 3 → WG Done (wgID)
└─ WG Wait (wgID)
└─ All Branches Complete - Aggregate Results

Wait for all 3 parallel branches to complete before continuing.

Example 2: Sequential Wait for Multiple Stages

WG Create → msg.stage1WG
└─ WG Add (stage1WG, Delta: 5)
└─ Launch 5 data fetchers
└─ WG Wait (stage1WG)
└─ Stage 1 Complete
└─ WG Create → msg.stage2WG
└─ WG Add (stage2WG, Delta: 3)
└─ Launch 3 processors
└─ WG Wait (stage2WG)
└─ All Processing Complete

Use sequential wait groups for multi-stage pipelines.

Example 3: Timeout with Parallel Monitoring

WG Create → msg.wgID
└─ WG Add (wgID, Delta: 10)
└─ Spawn 10 parallel tasks
└─ Fork:
├─ Branch A: WG Wait (wgID) → Success Path
└─ Branch B: Sleep (300 sec) → Timeout Path

Implement timeout logic by racing WG Wait against a sleep node.

Usage Notes

  • WG Wait blocks the flow execution until all parallel operations complete
  • The wait group is automatically deleted after Wait completes successfully
  • If no WG Done calls were made, WG Wait will block forever (ensure proper flow design)
  • WG Wait can only be called once per wait group - subsequent calls will error
  • The blocking is efficient (uses Go's sync primitives, not polling)
  • If parallel branches error out and never call WG Done, the Wait will hang indefinitely

Tips

  • Always ensure every parallel branch calls WG Done, even in error cases
  • Use timeouts or monitoring to prevent infinite waiting if branches might fail
  • Place WG Wait after all parallel branches have been spawned
  • Don't reuse Wait Group IDs - create a new one for each parallel operation set
  • Use Flow Designer to visually verify all parallel paths call WG Done
  • For debugging, add Debug nodes before WG Wait to log the current state
  • Consider using "Continue On Error" in parallel branches to ensure WG Done is reached
  • WG Create - Create the wait group first
  • WG Add - Set the expected completion count
  • WG Done - Signal completion from parallel branches