Cancellation Mechanisms
Timeout
Automatic cancellation after time limit
User-Initiated
Manual cancellation via API
External Signal
AbortController/AbortSignal support
Mid-Node
Check cancellation during long operations
Timeout-Based Cancellation
Set a timeout when executing:User-Initiated Cancellation
Cancel an execution manually:External Signal Cancellation
Use AbortController for external cancellation:Cancellation Reasons
CancellationReason
Execution exceeded timeout limit
CancellationReason
User explicitly cancelled via API
CancellationReason
Cancelled via AbortController/AbortSignal
CancellationReason
Resource constraints (reserved for future use)
Mid-Node Cancellation
Nodes can check for cancellation during long operations:Cancellation Events
Listen to cancellation events:Cancel All Executions
Cancel all active executions:Check Active Executions
Check if an execution is still running:React Integration
Implement cancellation in React components:Graceful Shutdown
Implement graceful shutdown with cleanup:Best Practices
Set Reasonable Timeouts
Set Reasonable Timeouts
Always set timeouts to prevent workflows from running indefinitely.
Check Cancellation in Loops
Check Cancellation in Loops
For nodes with loops, call
checkCancellation() in each iteration.Clean Up Resources
Clean Up Resources
Cancel network requests, close connections, and clear timers when cancelled.
Provide User Feedback
Provide User Feedback
Show cancellation status and allow users to cancel long operations.
Handle Cancellation Gracefully
Handle Cancellation Gracefully
Catch cancellation errors and clean up appropriately.
Complete Example
Next Steps
Error Handling
Handle execution errors
Execution & Events
Master the event system
Executor API
Complete Executor reference
Node API
Node class reference