Bull: Event "failed" is fired for every attempt [BUG]

Created on 17 Jul 2019  路  6Comments  路  Source: OptimalBits/bull

Description

It should be fired like "global:failed" only once after is job definitely failed.

Minimal, Working Test code to reproduce the issue.

``` 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
```

Bull version

3.10.0

Additional information

bug enhancement

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.

All 6 comments

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".

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ianstormtaylor picture ianstormtaylor  路  4Comments

inn0vative1 picture inn0vative1  路  4Comments

tdzienniak picture tdzienniak  路  4Comments

PhillippOhlandt picture PhillippOhlandt  路  4Comments

pintocarlos picture pintocarlos  路  3Comments