WG Done
Signals that a parallel running branch has completed for a specified Wait Group ID. This node decrements the initial count that is set by the WG Add node. When this counter reaches zero the WG Wait node continues the flow.
How It Works
- The node retrieves the Wait Group ID from the input variable
- The wait group is looked up in the global wait groups map using the ID
- A mutex lock is acquired to ensure thread-safe access
- If the internal delta counter is already 0, the node returns without decrementing (prevents negative counts)
- Otherwise, the delta counter is decremented by 1
- The sync.WaitGroup's Done() method is called, decrementing the internal wait counter
- The mutex is released
- If this was the last Done call (counter reached 0), any waiting WG Wait nodes are unblocked
- The message passes through unchanged
Requirements
- A valid Wait Group ID must be provided (from WG Create node)
- The wait group must exist (not yet deleted by WG Wait)
- WG Add must have been called before WG Done to set the counter
Error Handling
| Error Code | Description | Cause |
|---|---|---|
Core.WaitGroup.Done.ErrOnCreate | Config parse error | Invalid node configuration during creation |
Core.WaitGroup.Done.ErrOnMessage | Message parse error | Invalid message format received |
Core.WaitGroup.Done.Err | WaitGroup ID not found | The specified Wait Group ID doesn't exist |
Core.WaitGroup.Done.OutputMarshal | Output marshaling error | Failed to convert message to JSON |
Common Properties
- Name - The custom name of the node.
- 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 - The ID of the WaitGroup that a parallel running branch should be marked as completed.
Usage Examples
Example 1: Signal Completion of Parallel Task
Parallel Branch 1:
Fetch Data from API
└─ Process Response
└─ WG Done (msg.wgID)
Parallel Branch 2:
Fetch Data from Database
└─ Transform Data
└─ WG Done (msg.wgID)
Main Flow:
WG Wait (msg.wgID) → Waits for both branches
Each parallel branch calls WG Done when complete.
Example 2: Mark Loop Iteration Complete
WG Create → msg.wgID
└─ WG Add (wgID, Delta: items.length)
└─ For Each (items)
└─ Trigger Parallel Flow
└─ (In parallel flow)
Process Item
└─ WG Done (msg.wgID)
└─ WG Wait (wgID)
Each loop iteration triggers a parallel flow that calls WG Done upon completion.
Example 3: Conditional Completion
Parallel Worker:
Try Process Task
└─ Catch Error
└─ Handle Error
└─ Finally
└─ WG Done (msg.wgID) // Always signal done, even on error
Ensure WG Done is always called, even if the task fails.
Usage Notes
- WG Done decrements the counter by exactly 1 each time it's called
- If the counter is already 0, calling WG Done has no effect (safe to call redundantly)
- Always ensure WG Done is called for every parallel operation, including error cases
- The number of WG Done calls must match the sum of all WG Add deltas
- WG Done is thread-safe and can be called simultaneously from multiple parallel branches
- Once the counter reaches 0, any waiting WG Wait nodes immediately continue
Tips
- Place WG Done at the end of each parallel branch to signal completion
- Use Finally blocks or defer patterns to ensure WG Done is called even on errors
- If a branch might error out, set "Continue On Error" to true to ensure WG Done is reached
- For loops spawning parallel work, call WG Done at the end of each spawned task
- Never call WG Done more times than you called WG Add - this will cause issues
- Use Debug nodes before WG Done to log completion status for troubleshooting