Skip to main content
Some workflows need to do multiple things at once — look up company data from three APIs simultaneously, enrich 50 leads in a batch, or run quality checks in parallel after generating content. executeInParallel handles this: run multiple steps concurrently with optional rate limiting, and get all results back in order.

Basic Usage

Wrap each job in an arrow function and pass them as an array. Results come back in the same order you submitted them, with each result telling you whether the job succeeded or failed:
workflow.ts

Parameters

Result Type

The function returns Promise<Array<ParallelJobResult<T>>>, sorted by original job index (so results stay in the same order you submitted them). Each element is a discriminated union: Handling successes and failures:

Concurrency Limit

When you’re calling an external API that has rate limits, use concurrency to cap how many jobs run at once:
With concurrency: 3, at most three enrichment calls run at a time. When one finishes, the next starts.

onJobCompleted Callback

onJobCompleted fires once per job in completion order (fastest first), not submission order. Use it for logging progress or streaming partial results:

Examples

Batch enrichment with rate limiting

Enrich a list of leads, capping concurrency to respect API rate limits:
workflow.ts

Gather data from multiple sources

Run different steps in one batch — results stay in job order:

Child workflows in parallel

Run multiple child workflows with a concurrency cap:

Important: Wrap in arrow functions

Jobs must be functions that return the step, evaluator, or child workflow call. Do not pass promises:
Passing promises would start all work immediately and break determinism; wrapping in functions lets executeInParallel control when each job runs and respect the concurrency limit.