You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
documentation states that success and success:job name events will be emitted only when a job succeeds, but if the job is failed manually by calling job.fail(err).save(); the messages will be emitted anyway.
constagenda=newAgenda();consthandler=(job)=>job.fail('error').save();agenda.define('test',handler);agenda.on('success',()=>console.log('success'));awaitagenda.start();awaitagenda.now('test');// will print 'success' even if the job has failed
@riddlewiggler yes, i forgot that part on the example, still the problem is not that the job is executed.
what happens is:
job is executed
job is manually failed (and disabled) in the handler
handler returns
agenda emits success message, even if the job has failed
yes, i saw that fail() will only set the fail reason and update the failCount on the job, but I would have expected Agenda to check the status of the job before emitting success or fail, whereas it seems fail will be emitted if the handler throws an exception, and success will be emitted when the handler returns, regardless of the status of the job.
I don't think this was mentioned in the documentation, if it is the desired behavior I think it should be clarified, since it was clear to me only after inspecting the code.
documentation states that
success
andsuccess:job name
events will be emitted only when a job succeeds, but if the job is failed manually by callingjob.fail(err).save();
the messages will be emitted anyway.link to code
The text was updated successfully, but these errors were encountered: