Overview
Stepkit allows you to execute multiple functions in parallel within a single step. This is useful for gathering data from multiple sources concurrently, improving pipeline performance.Basic Parallel Execution
Pass multiple functions to a single.step() call to run them in parallel:
Parallel Modes
Control how parallel execution handles failures using theparallelMode configuration:
Determines how parallel step execution handles failures:
'all': All parallel functions must succeed (usesPromise.all)'settled': Continue merging successful outputs even if some functions fail (usesPromise.allSettled)
Mode: all (default)
If any function fails, the entire step fails:
Mode: settled
Continue merging successful outputs even if some functions fail:
When using
parallelMode: 'settled', downstream steps should handle potentially undefined values from failed parallel functions.Merge Policies
Control how outputs are merged when parallel functions return overlapping keys:Determines how to handle key collisions when merging step outputs:
'override': Later values overwrite earlier ones (default)'error': Throw an error on key collision'warn': Log a warning and override'skip': Keep the first value, skip the duplicate
Mixed Parallel and Sequential Execution
Combine parallel execution with sequential steps:Parallel Execution with Sub-Pipelines
You can also nest pipelines as parallel functions:Type Safety
Parallel outputs are properly typed and merged:Performance Considerations
- Parallel execution uses
Promise.all()orPromise.allSettled()under the hood - All parallel functions start simultaneously
- The step completes when all functions finish (or when all settle in
settledmode) - Use parallel execution for I/O-bound operations that can run independently
- CPU-bound operations may not benefit from parallel execution in Node.js