I may be misunderstanding clean, but queue.clean(0, 'active') isn't removing active jobs for me.
var queue = new Queue('foo', 'redis://127.0.0.1:6379');
await queue.clean(0, 'active');
var jobs = await queue.getActive();
console.log(`active: ${jobs.length}`); //active: 4
Even if I try to nuke it, they don't go away:
await queue.pause();
await queue.empty();
await queue.clean(0);
await Promise.all(["completed","wait","active","delayed","failed"].map(async status => {
await queue.clean(0, status);
}));
Here's one of the actual jobs that is "active":
{
"id": "1575083022-testconsumer-75211a16",
"name": "__default__",
"data": {
"consumerId": "test-consumer",
"delay": 2000,
"error": null
},
"opts": {
"jobId": "1575083022-testconsumer-75211a16",
"attempts": 3,
"timeout": null,
"removeOnComplete": true,
"delay": 0,
"timestamp": 1575083022241
},
"progress": 0,
"delay": 0,
"timestamp": 1575083022241,
"attemptsMade": 2,
"failedReason": "Unexpected exit code: 7 signal: null",
"stacktrace": [
"Error: Unexpected exit code: 7 signal: null\n at ChildProcess.exitHandler (.../web/node_modules/bull/lib/process/sandbox.js:41:13)\n..."
],
"returnvalue": null,
"finishedOn": null,
"processedOn": 1575083028947
}
Bull: 3.12.0
Node: 12.13.0
Yes, both clean and empty fail to do anything it seems.
I can confirm this - can't get rid of an active job.
Example Job that reproduces issue for me (next is not called):
function(job, next){
console.log('here')
}
Same here, it seems removeRepeatable doesn't work. Repeatable job still triggers process function and logs the time.
Any ideas?
package.json
"dependencies": {
"bull": "^3.14.0"
}
index.js
const Bull = require('bull');
const myFirstQueue = new Bull('my-first-queue');
const conf = {
repeat: {
every: 1000
}
};
myFirstQueue.add('remove', { foo: 'bar' }, { conf });
myFirstQueue.process(async (job) => {
console.log(`trying job ${new Date().toISOString()}`);
})
setTimeout(() => {
myFirstQueue.removeRepeatable('remove', conf).then(() => {
console.log('SHOULD BE DEAD')
})
}, 5000);
I already looked at this https://github.com/OptimalBits/bull/blob/develop/test/test_repeat.js#L362
The code above is wrong, starting with this line
myFirstQueue.add('remove', { foo: 'bar' }, { conf });
Since conf is not a valid option.
Hello @manast , thanks for you answer. Actually I didn't understand why it is not valid option because job is working as expected. conf has all the needed keys, repeat for JobOptions and every for EveryRepeatOptions.
Can you give me an insight about the mistake please?
@TayfunCesur you've used object property value shorthand in job options, so the repeat key is actually nested inside conf object.
This should fix it: myFirstQueue.add('remove', {foo: 'bar'}, conf);
Or this: myFirstQueue.add('remove', {foo: 'bar'}, {...conf});
@DominikSerafin Thank you so much for your help.
I will try it ASAP :)
Will close this since original code was not correct. Please open new issue with working code if necessary.