You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to documentation, removeOnComplete job option allows us to configure maximum age for a job to be kept after completion, in seconds. However, the check for expired completed jobs appears to only be done after another job is processed.
Expected Behavior
Setting age property on removeOnComplete should limit how many seconds a job is kept after being completed. Job should be automatically removed after specified time.
Current Behavior
Job is removed based on ageonly after another job in the same queue is processed, which could lead to cases where jobs could be kept for indefinite time, if no new jobs are added to the queue. This behaviour is different if you set removeOnComplete: true or removeOnComplete: {count: 0} - here, job is immediately and correctly deleted at completion.
Steps to Reproduce
Create a Queue and QueueScheduler with defaultJobOptions:
constworker=newWorker("queue",async(job)=>{console.log(`Job ${job.name}#${job.id} is processed.`);});worker.on("completed",(job)=>console.log(`Completed job ${job.name}#${job.id} with data ${job.data}`));
Add job to queue:
queue.add("job",{random: "data"});
Checking situation in redis shows us that job is not automatically removed.
The text was updated successfully, but these errors were encountered:
benja8151
changed the title
Removing completed jobs based on age not working properly
Removing completed jobs based on age not working as expected
Aug 8, 2022
The feature is working as designed.
This may not be the desirable behaviour in some situations, but for most cases, when you have a healthy queue processing jobs regularly it should not be a big issue.
According to documentation,
removeOnComplete
job option allows us to configure maximum age for a job to be kept after completion, in seconds. However, the check for expired completed jobs appears to only be done after another job is processed.Expected Behavior
Setting
age
property onremoveOnComplete
should limit how many seconds a job is kept after being completed. Job should be automatically removed after specified time.Current Behavior
Job is removed based on
age
only after another job in the same queue is processed, which could lead to cases where jobs could be kept for indefinite time, if no new jobs are added to the queue. This behaviour is different if you setremoveOnComplete: true
orremoveOnComplete: {count: 0}
- here, job is immediately and correctly deleted at completion.Steps to Reproduce
Queue
andQueueScheduler
withdefaultJobOptions
:Worker
:The text was updated successfully, but these errors were encountered: