calling done with error doesnt fail the job on Arena
sharonass opened this issue · comments
I've setup a bee-queue with arena and In my local machine when I call
queue.process(async function (job, done) {
console.log(`Processing job ${job.id}`);
job.reportProgress(5);
let res = await my_service.execute(job);
if(res.status) {
//report job progress
job.reportProgress(100);
return done(null, res.msg);
} else {
done(new Error(res.msg));
}
});
I see on my flow that the done(new Error(res.msg)); is being called and I also debugged the done function and I see it rejects the promise. however when I look at the job on Arena I see it in success section
I also dont get fail event
queue.on('failed', (job, err) => {
console.log(Job ${job.id} failed with error ${err.message}
);
});
@sharonass I think the problem is that if you pass an async
function (or a promise) the done
callback will be useless
See docs:
N.B. If the handler returns a Promise, calls to the done callback will be ignored.
https://github.com/bee-queue/bee-queue#queueprocessconcurrency-handlerjob-done
Aha, I was a bit puzzled here but @dylanjha I think you hit the nail on the head.
I would replace:
return done(null, res.msg);
...
done(new Error(res.msg));
with:
return res.msg;
...
throw new Error(res.msg);