Introduction

YieldStar is a TypeScript framework for writing and running distributed workflows.

Each workflow yields steps — discrete units of work that the runtime persists, caches, retries, and resumes across process restarts.

When steps are yielded, the runtime snapshots its output and then either continues the workflow or yields back to the orchestrator. When a workflow is resumed by the orchestrator, already completed steps yield their snapshoted values back into the generator function, allowing the workflow to continue from where it left off without re-executing steps.

import { workflow } from "yieldstar";

const checkout = workflow(async function* (step) {
  const order = yield* step.run(() => createOrder());
  yield* step.delay(30_000);
  const payment = yield* step.run(() => chargeCard(order.id));
  return yield* step.run(() => confirmOrder(order.id, payment.id));
});

YieldStar runs on Bun with SQLite persistence today. Postgres support is in progress.

Packages

YieldStar is a monorepo of composable packages:

PackageRole
yieldstarCore SDK — workflow, createWorkflowRouter, RetryableError, local and HTTP SDKs
@yieldstar/coreBase types and the WorkflowRunner execution engine
@yieldstar/bun-sqlite-runtimeSQLite-backed heap, scheduler, task queue, timers, and event loop
@yieldstar/bun-worker-invokerBun subprocess invoker and worker process
@yieldstar/bun-http-serverHTTP routes and middleware for triggering workflows over the network

The runtime splits into four concerns: a heap stores step results, a scheduler manages wake-ups, a task queue orders pending work, and an event loop polls the queue and dispatches executions. The invoker spawns a worker process per execution, which runs the workflow generator against the heap and yields control back when async work (delays, retries) is required.