-
Notifications
You must be signed in to change notification settings - Fork 221
Job not removed from queue.jobs after calling queue.removeJob(id) #150
Copy link
Copy link
Closed
Description
Hello,
I was hit by a strange problem and I would like to clarify if this is intended behaviour or a bug.
This was my code:
queue.getJob(id, (err, job) => {
if (job) {
job.remove()
.then(() => { /* job is removed */ });
} else {
// job does not exist
}
});With first invocation everything is as expected. Job existed and job.remove() block is run. After job is removed, when I do getJob(id) again I expect it to invoke callback with null job (job does not exist), but this is not the case. After first invocation, job is removed from Redis, but it stays in local jobs list from where it is find when I call queue.getJob(id) again.
To w/a this problem I had to do the following:
queue.getJob(id, (err, job) => {
if (job) {
job.remove()
.then(() => {
queue.jobs.delete(id);
});
} else {
// job does not exist
}
});But I would expect this to be done under the hood so as the API user I do not have to care about internal impl or cache.
Can you please clarify?
Reactions are currently unavailable