Durable operations
Register work and its earliest wake-up in one storage transaction.
Durability is an open-source toolkit for SQLite-backed Cloudflare Durable Objects. Its main package persists operations and logical alarms, retries failures, deduplicates stable IDs, and exposes typed results while sharing the Durable Object’s single physical alarm safely.
npm install durabilityDurable operations
Named alarms
Typed RPC transforms
Safety tooling
import { DurableObject } from 'cloudflare:workers';import { createDurability, type DurableHandler } from 'durability';
type ResizeInput = { imageId: string };
export class ImageJobs extends DurableObject<Env> { private readonly durability = createDurability(this.ctx, { resizeImage: (async ({ id, payload, signal }) => { return this.env.IMAGES.resize(payload.imageId, { idempotencyKey: id, signal, }); }) satisfies DurableHandler<ResizeInput, string>, });
resize(imageId: string) { return this.durability.resizeImage({ id: `resize:${imageId}`, payload: { imageId }, }); }
alarm(info?: AlarmInvocationInfo) { return this.durability.alarm(info); }}The generated operation method resolves after registration commits. It does not wait for the handler result.
alarm() method to Durability.Continue with the quickstart, named alarms, or package map.