ReliabilityRetries and backoff

Retries and backoff

A job that throws isn't a failed job until it runs out of attempts. Until then, Taskwire puts it back on the queue with a longer wait each time, so a struggling dependency gets room to recover instead of a stampede.

How the delay grows

Each retry waits base × factorn−1, held at maxDelay, then spread by jitter so a thousand failed jobs don't all wake in the same second.

Backoff visualizer

    Configure a job

    Retries are built into the core package from 4.0, so there's nothing extra to add unless you're upgrading.

    Set the policy on the job definition. The highlighted lines are the ones the visualizer writes for you.

    Attempts include the first run. attempts: 6 means one run and five retries. Set it to 1 to turn retries off for a job.

    Defaults for a whole queue

    A policy on the queue applies to every job in it. Anything set on a job wins, field by field, so a job can change attempts and keep the queue's backoff.

    Parameters

    All of these go under retry on a job or a queue. Durations are strings such as "500ms", "2s" or "5m".

    NameTypeDefaultWhat it does

    Retry only what can recover

    Every thrown error is retried by default, which wastes attempts on failures that will never succeed, like a validation error or a 404. Pass retryOn to decide per failure: return true to follow the policy, false to give up now, or { after } to wait for a specific time.

    Handlers can run more than once. If a worker dies after a charge goes through but before the job is marked done, the next attempt charges again. Guard side effects with an idempotency key.

    When attempts run out

    A job that uses its last attempt moves to the queue's dead-letter list, along with its payload, its final error and its attempt history. It stays there for 14 days. onGiveUp runs once, right after the move, which makes it a good place to tell someone.

    Replay from the command line

    Fixed the bug? Send the dead jobs back through with a fresh set of attempts. Add --dry-run to see what would go first.

    Watch retries in production

    A rising retry rate is usually the first sign of a dependency in trouble, well before anything reaches the dead-letter list. The metrics exporter adds three counters, each labelled by queue and job name.

    • taskwire_job_attempts_totalEvery run, including the first.
    • taskwire_job_retries_totalRuns that followed a failure. Alert on this one first.
    • taskwire_job_dead_totalJobs that used their last attempt.
    Was this helpful?

    Updated 14 October 2026Taskwire is MIT licensed. Docs under CC BY 4.0.

    esc
    ↑↓ move↵ open/ or ⌘K anywhere