Skip to content
Get started
Get started
Worker Error Handling, Retries and Backoff
guide · worker

When the processor throws.

A failed attempt is not a lost job. bunqueue counts the attempt, waits a widening backoff, tries again, and only after the budget runs out does the job become permanently dead.

Throwing inside the processor fails the current attempt; bunqueue retries with backoff (a growing wait between attempts) until attempts is exhausted:

const worker = new Worker('queue', async (job) => {
await riskyOperation(); // Just let errors throw, retries are automatic
}, { embedded: true });
worker.on('failed', (job, error) => {
console.warn(`Attempt ${job.attemptsMade + 1} failed`, error);
});

The failed listener fires after each broker-confirmed failed attempt, not only after retry exhaustion. The job snapshot was pulled before that failure, so the attempt that just failed is attemptsMade + 1 (Bun), attempts + 1 (TypeScript/Python). PHP and Go do not expose maxAttempts on their Job view; use the queue’s DLQ operations for authoritative terminal-failure alerts. Rust and Elixir record per-job outcomes in normal processor control flow and expose transport/retry failures through telemetry; see the SDK guide.

A processing timeout can win while user code is still running. In that race, the broker has already recorded the failed attempt. The Bun Worker treats the late processor result or exception as an acknowledged no-op: it emits neither a second completed/failed event nor a Worker error, and a newer retry lease remains free to finish normally.

WorkerCreate a worker and process your first job
Worker Concurrency and Batch PullingRun jobs in parallel and pull them in batches
The Job Object Inside a Worker ProcessorEverything the processor receives and can do
Worker Eventscompleted, failed, stalled and the rest
Worker LifecyclePause, resume and shut down without losing work
Heartbeats, Stall Detection and Lock OwnershipHeartbeats, stall recovery and lock ownership
SandboxedWorkerExperimental isolation for CPU-heavy handlers
WorkerOptions ReferenceEvery WorkerOptions field, with defaults