Skip to main content

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

SignalDescription
DoStarts the task execution process.
AbortStops all currently running and queued tasks immediately.

Configuration

DataDescription
TemplateThe Component to use as the task processor. This component must have specific inputs/outputs (see Usage).
Stop On FailureIf true, the entire process halts if a single task reports failure. Default: false.
Max Running TasksThe maximum number of tasks to run simultaneously (concurrency limit). Default: 10.

Data

DataDescription
ItemsThe array of data objects to process. Each object will be passed to a task instance.

Outputs

Events

SignalDescription
SuccessTriggered if all tasks completed successfully.
FailureTriggered if any task failed (and Stop On Failure is true, or after all finished if false).
DoneTriggered when processing is finished, regardless of success/failure.
AbortedTriggered 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:

  1. Inputs:
    • It should accept inputs matching the properties of your data items (e.g., if your items have a url property, the component should have a url input).
    • It receives a Do signal automatically when the task starts.
  2. Outputs:
    • It MUST have a Success signal output.
    • It MUST have a Failure signal output.
    • Triggering either of these signals tells the Run Tasks node that this specific task is finished.

Example Scenario: Batch Image Upload

  1. Data: An array of objects: [{ path: "img1.jpg" }, { path: "img2.jpg" }].
  2. Template Component: "Upload Image Task".
    • Has input path.
    • Internal logic: Uploads file at path.
    • On upload complete -> Trigger Success.
    • On error -> Trigger Failure.
  3. 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

  1. Queueing: When Do is triggered, all items are added to a queue.
  2. Spawning: The node spawns up to Max Running Tasks instances of the template.
  3. Data Injection: Each instance receives the data from one array item.
  4. Execution: The Do signal is sent to the instance.
  5. Completion: When an instance fires Success or Failure, it is destroyed, and the next item in the queue is processed.
  6. Final State: Once the queue is empty and all running tasks finish, the final Success/Failure/Done signals are emitted.

Troubleshooting

  • Stuck Tasks: If your template component never fires Success or Failure, 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.