Run Tasks
This node executes a list of tasks sequentially or in parallel using a component template.
The Run Tasks node is a powerful flow control node for processing arrays of data by spawning a sub-component for each item.
The Run Tasks node iterates over an array of items. For each item, it creates a new instance of a specified Component (the "Task Template"). It passes the item data to that component and waits for the component to signal "Success" or "Failure". It manages the queue, concurrency limits, and overall completion state.
Inputs
General
| Signal | Description |
|---|---|
| Do | Starts the task execution process. |
| Abort | Stops all currently running and queued tasks immediately. |
Configuration
| Data | Description |
|---|---|
| Template | The Component to use as the task processor. This component must have specific inputs/outputs (see Usage). |
| Stop On Failure | If true, the entire process halts if a single task reports failure. Default: false. |
| Max Running Tasks | The maximum number of tasks to run simultaneously (concurrency limit). Default: 10. |
Data
| Data | Description |
|---|---|
| Items | The array of data objects to process. Each object will be passed to a task instance. |
Outputs
Events
| Signal | Description |
|---|---|
| Success | Triggered if all tasks completed successfully. |
| Failure | Triggered if any task failed (and Stop On Failure is true, or after all finished if false). |
| Done | Triggered when processing is finished, regardless of success/failure. |
| Aborted | Triggered if the Abort signal was received. |
Usage
This node is essential for batch processing, such as uploading multiple files, syncing a list of records, or running a complex calculation on every item in a list.
Setting up the Task Template
The component you connect to Template must follow a specific contract:
- Inputs:
- It should accept inputs matching the properties of your data items (e.g., if your items have a
urlproperty, the component should have aurlinput). - It receives a
Dosignal automatically when the task starts.
- It should accept inputs matching the properties of your data items (e.g., if your items have a
- Outputs:
- It MUST have a
Successsignal output. - It MUST have a
Failuresignal output. - Triggering either of these signals tells the Run Tasks node that this specific task is finished.
- It MUST have a
Example Scenario: Batch Image Upload
- Data: An array of objects:
[{ path: "img1.jpg" }, { path: "img2.jpg" }]. - Template Component: "Upload Image Task".
- Has input
path. - Internal logic: Uploads file at
path. - On upload complete -> Trigger
Success. - On error -> Trigger
Failure.
- Has input
- Run Tasks Node:
- Connect Data to Items.
- Connect "Upload Image Task" to Template.
- Set Max Running Tasks to
3(upload 3 at a time). - Trigger Do.
Detailed Behavior
- Queueing: When Do is triggered, all items are added to a queue.
- Spawning: The node spawns up to
Max Running Tasksinstances of the template. - Data Injection: Each instance receives the data from one array item.
- Execution: The
Dosignal is sent to the instance. - Completion: When an instance fires
SuccessorFailure, it is destroyed, and the next item in the queue is processed. - Final State: Once the queue is empty and all running tasks finish, the final
Success/Failure/Donesignals are emitted.
Troubleshooting
- Stuck Tasks: If your template component never fires
SuccessorFailure, the Run Tasks node will wait forever (or until Aborted). Ensure every possible path in your component leads to a result signal. - Inputs Not Mapping: Ensure the input names in your Template Component exactly match the property keys in your data objects.