job.on('failed') is called on first failed attempt, regardless if the job is set to retry #142

Closed
garo opened this Issue Oct 16, 2012 · 2 comments

Comments

Projects
None yet
3 participants

garo commented Oct 16, 2012

It seems that if a job try fails the job state is changed to 'failed' and thus the client will get the on('failed') call.

Example client code:

var job = jobs.create('my job', jobData).attempts(5);

job.on('complete', function (err, res) {
console.log("job completed. err:", err, ", res:", res);
callback(err, res);
}).on('failed', function (err, res) {
console.log("job failed. err:", err, ", res:", res);
callback(err, res);
});
job.save();

Example server code:

jobs.process('my job', 5, function (job, done) {
done('error happens on first try');
});

Here the .on('failed' is called after the first attempt has failed. In my opinion it should be called only when all job attempts have failed. Another choice would be to distinct a single attempt failure from the job failure with another state event.

habicm commented Aug 15, 2013

I found same issue here. Do you think to include this in a future version?

behrad was assigned Jan 21, 2014

Collaborator

behrad commented Jan 21, 2014

fixed in LearnBoost#256

behrad closed this Jan 21, 2014

behrad was unassigned by garo Mar 24, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment