BullMQ worker with retries + dead-letter

8832
0

Background jobs will fail in production, so I like having a predictable story for retries and poison messages. BullMQ is a solid middle ground: Redis-backed, straightforward, and good enough for most apps. I set explicit attempts and backoff, and when a job keeps failing I push it to a DLQ (dead-letter queue) for human inspection instead of retrying forever. For side-effecting work (emails, payments), I include an idempotency key in the job payload and design the handler to be safe on re-run. The core insight is that retries must be safe by design—don’t rely on ‘it probably won’t run twice’, because eventually it will.