durable-execution
SourceA durable execution engine for TypeScript tasks and workflows, published to npm as five packages
durable-execution runs TypeScript tasks and workflows so they survive logic failures, process crashes and network errors instead of vanishing with the process that ran them. It's on npm as five MIT-licensed packages, with storage for Convex and Drizzle and documentation that includes the full state diagram.
How it works
A task is a single function or a parent that returns child tasks, which run in parallel. An optional finalize task receives every child's result, failed ones included, and decides the parent's output. The executor stores each execution and moves it through explicit states: ready, running, then completed, failed, timed_out or cancelled.
For recovery, a running task gets an expiry from its timeout plus some leeway, and a background process resets any task still running past its expiry to ready, so a crash loses no state. Tasks must be idempotent, because a task can run more than once.
Sleeping tasks wait for an outside signal, such as a payment webhook or an approval. Cancellation is stored too, so whichever executor is running a task stops it.
The executor runs in the app's process or as its own server. The packages are:
- durable-execution, the core engine, built on Effect
- durable-execution-storage-convex, storage on Convex
- durable-execution-storage-drizzle, storage on PostgreSQL, MySQL or SQLite through Drizzle
- durable-execution-storage-test-utils, a test suite for any storage implementation
- durable-execution-orpc-utils, type-safe RPC with oRPC for running the executor as a server