Overview
start() initiates a new workflow execution and returns a Run object for tracking and interacting with the workflow. It handles argument serialization, event sourcing, and queuing the workflow for execution.
Usage
Signature
Parameters
WorkflowFunction | WorkflowMetadata
required
The workflow function to start. Must have a
'use workflow' directive and be properly compiled.TArgs
Arguments to pass to the workflow function. Must be serializable.
StartOptions
Returns
Examples
Basic Workflow Start
No Arguments
With Options
Start and Monitor
Start and Stream Results
Parallel Workflow Starts
Type-Safe Workflow Starts
Using Workflow Metadata
Error Handling
Run ID Generation
Each workflow run gets a unique ID in the formatwrun_{ulid}. The ID is:
- Generated client-side before execution
- Globally unique and sortable by creation time
- Used for tracking, logging, and event correlation
Serialization
Workflow arguments must be serializable. Supported types:- Primitives: string, number, boolean, null, undefined
- Objects and arrays
- Dates
- URLs
- Custom classes with proper serialization
- Streams (automatically handled)
Trace Propagation
start() automatically propagates OpenTelemetry trace context to the workflow:
Best Practices
-
Await the start call: Always await
start()to ensure the workflow is queued -
Store run IDs: Save
run.runIdfor later reference and monitoring - Use type inference: Let TypeScript infer return types from workflow functions
- Handle start errors: Catch and handle errors from the start call separately from execution errors
- Serialize carefully: Ensure all arguments are serializable before passing to workflows
- Don’t start workflows from workflows: Use direct function calls or steps instead