Execution Basics
Execute a workflow with theExecutor:
Execution Options
Event System
The Executor emits events throughout the workflow lifecycle:Lifecycle Events
1
beforeExecute
Fired before workflow execution starts
2
onNodeStart
Fired when each node starts executing
3
onNodeComplete
Fired when each node completes successfully
4
onNodeError
Fired when a node encounters an error
5
afterExecute
Fired after workflow execution completes
Event Listeners
Before Execution
Node Start
Node Complete
Node Error
After Execution
General Error Handler
Async Event Handlers
All event listeners support async functions - the executor waits for them:Execution Result
The execution returns a detailed result object:Accessing Node Results
Complete Example
Cancellation Events
Progress Tracking
Track execution progress with event counts:UI Integration
Integrate events with React UI:Best Practices
Always Handle Errors
Always Handle Errors
Use
onError and onNodeError listeners to handle failures gracefully.Clean Up Resources
Clean Up Resources
Clean up resources in async event handlers (close connections, clear timers).
Avoid Heavy Computation
Avoid Heavy Computation
Keep event handlers lightweight - don’t block execution with heavy operations.
Use Async for I/O
Use Async for I/O
Use async handlers for database writes, API calls, and file operations.
Monitor Performance
Monitor Performance
Use timing data from results to identify slow nodes.
Next Steps
Executor API
Complete Executor API reference
Error Handling
Advanced error handling patterns
Cancellation
Cancelling workflow execution
Execution Engine
Understanding the engine