Skip to main content
CrystalFlow’s execution engine provides a powerful event system for monitoring and controlling workflow execution.

Execution Basics

Execute a workflow with the Executor:

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

Cancellation events: The onCancellation event is available for tracking cancelled executions.

Progress Tracking

Track execution progress with event counts:

UI Integration

Integrate events with React UI:

Best Practices

Use onError and onNodeError listeners to handle failures gracefully.
Clean up resources in async event handlers (close connections, clear timers).
Keep event handlers lightweight - don’t block execution with heavy operations.
Use async handlers for database writes, API calls, and file operations.
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