OptionalbyJobProcessor: booleanReadonlyagendaReadonlyattrsinternal variable to ensure a job does not set unlimited numbers of setTimeouts if the job is not processed immediately
Optionalerror: ErrorConfigure debounce behavior for this job. Debouncing delays job execution and resets the timer on subsequent saves, ensuring the job only runs once after a quiet period.
IMPORTANT: Requires a unique constraint to be set via .unique().
The unique constraint identifies which jobs should be debounced together.
Debounce window in milliseconds
Optionaloptions: { maxWait?: number; strategy?: "trailing" | "leading" }Optional configuration (maxWait, strategy)
// Basic trailing debounce - execute 2s after last save
await agenda.create('updateIndex', { entityId: 123 })
.unique({ 'data.entityId': 123 })
.debounce(2000)
.save();
// With maxWait - guarantee execution within 30s
await agenda.create('syncUser', { userId: 456 })
.unique({ 'data.userId': 456 })
.debounce(5000, { maxWait: 30000 })
.save();
// Leading strategy - execute immediately, ignore subsequent calls
await agenda.create('notify', { channel: '#alerts' })
.unique({ 'data.channel': '#alerts' })
.debounce(60000, { strategy: 'leading' })
.save();
Prevents the job from running
Allows job to run
Sets the end date for the job. The job will not run after this date (nextRunAt will be set to null).
Fails the job with a reason (error) specified
if set, a job is forked via node child process and runs in a seperate/own thread
A job is running if: (lastRunAt exists AND lastFinishedAt does not exist) OR (lastRunAt exists AND lastFinishedAt exists but the lastRunAt is newer [in time] than lastFinishedAt)
Whether or not job is running at the moment (true for running)
Sets priority of the job
priority of when job should be queued
Remove the job from database
Sets a job to repeat at a specific time
Saves a job to database
Schedules a job to run at specified time. Date constraints (startDate, endDate, skipDays) are applied if set.
Sets the days of the week to skip. The job will not run on these days.
Array of days to skip (0 = Sunday, 1 = Monday, ..., 6 = Saturday)
Sets the start date for the job. The job will not run before this date.
Given a job, turn it into an JobParameters object
If true, excludes fields managed by the job processor
Updates "lockedAt" time so the job does not get picked up again
Optionalprogress: number0 to 100
Data to ensure is unique for job to be created
Optionalopts: UniqueOpts
creates a new job object