Configuring Queues
When specifying a queue, you can optionally pass an options
object to customize the queue’s behavior.
There’s currently 1 option you can customize:
maxAttempts
- Default is 1. Increasing this means your job will be retried untilcurrentAttempt <= maxAttempts
.
maxAttempts
By increasing the maxAttempts
for a job, you are allowing the job to be retried in the future. All jobs have a default maxAttempts
of 1, so if you want a job to run at most 5 times before being marked as failed, you can set maxAttempts to 5.
import { } from "sidetrack";
const = new <{
: { : string };
}>({
: {
: .["DATABASE_URL"]!,
},
: {
: {
: async () => {
throw new ("intentionally failing job");
},
: {
maxAttempts?: number | undefined
maxAttempts: 5,
},
},
},
});
.();
.("userOnboarding", { : "a@example.com" });
This job will fail on the first run then move to retrying
status since its currentAttempt
(1) is less than 5. After 5 attempts, the job will transition to a status of failed
.