Persistent
Pending calls survive eviction and restarts in SQLite.
@repo/durability registers operations in Durable Object SQLite storage and executes them through alarms or background timers. It provides stable call IDs, bounded retries, attempt timeouts, concurrency controls, and typed result lookup.
getResult(id).Persistent
Typed
Bounded
Idempotent
import { DurableObject } from 'cloudflare:workers';import { createDurability, type DurableHandler } from '@repo/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(alarmInfo?: AlarmInvocationInfo) { return this.durability.alarm(alarmInfo); }}Continue with setup and execution or review reliability semantics.