await queue.add("send-invoice", { id: 42 }, {
attempts: 3,
backoff: { type: "exponential", delay: 1000 },
});
3 times in total, waiting about 1s and then 2s
The job runs 3 times in total, waiting about 1 s and then 2 s. attempts is the total number of tries, and it includes the first try. So the job runs 3 times and then moves to failed. Exponential backoff waits 2^(attemptsMade - 1) * delay between tries. This gives 1000 ms after the first try and 2000 ms after the second.
The option "4 times: once plus 3 retries, waiting 1s, 2s and 4s" is wrong. It treats attempts as a count of retries, but it is a count of all tries.
Read more