It should be fired like "global:failed" only once after is job definitely failed.
``` node js
let Queue = require("bull");
let queue = new Queue("queue", { defaultJobOptions: { attempts: 3 } });
queue.process(_job => { throw(new Error("err")); });
queue.on("failed", job => console.log("failed", job.id, job.attemptsMade, job.opts.attempts));
queue.on("global:failed", job_id => console.log("global:failed", job_id));
queue.add({});
Possible output:
failed 358 1 3
failed 358 2 3
global:failed 358
failed 358 3 3
```
3.10.0
I can take this as a feature request, but not as a bug since it works like this as designed.
Ok, but who would expect such difference between local and global version of event?
aha, global only is emitted once but local for every retry. Then I agree, it is a bug.
Maybe it is not so bad to have some separate event fired on failed attempt "failed_attempt". But I suppose "failed" everywhere else means "definitely failed". Or at least I hope that functions like getFailed, getFailedCount, getState are working with "definitely failed" concept like "global:failed" event. There is nothing about that in reference.
so I think the current failed event should mean definitive fail, and we could have a new event "retry" to signal every retry.
New failed_attempt event would be really useful.
Note, for those who struggle with making a difference between failed job and failed_attempts there is job attribute finishedOn Unix Timestamp, which is set when job is "definitely and finally failed".
Most helpful comment
so I think the current failed event should mean definitive fail, and we could have a new event "retry" to signal every retry.