background-jobsasync
Run background jobs
Queue and worker patterns for async work outside your request path.
Not every operation belongs in a request path. Long ingestions, fan-out notifications, and third-party API retries should run as background jobs that the request hands off and returns from immediately.
1. Pick a queue
DeesseJS uses Postgres as the queue substrate. The
jobs table is provisioned by the database package;
the worker binary in @deessejs/cli reads from it.
2. Enqueue
import { enqueue } from "@workspace/queue"
await enqueue("send-welcome-email", { userId: user.id })
3. Worker
pnpm --filter @workspace/cli worker
The worker is a long-running process that picks up jobs in FIFO order, runs the handler, and retries with exponential backoff on failure.
What's next
- Add observability — track job duration and retry rate.
- Production readiness checklist — verify queue depth alarms before going live.