Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

calling done with error doesnt fail the job on Arena #95

Closed
sharonass opened this issue Jan 14, 2018 · 3 comments
Closed

calling done with error doesnt fail the job on Arena #95

sharonass opened this issue Jan 14, 2018 · 3 comments

Comments

@sharonass
Copy link

sharonass commented Jan 14, 2018

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

@sharonass
Copy link
Author

I also dont get fail event

queue.on('failed', (job, err) => {
console.log(Job ${job.id} failed with error ${err.message});
});

@dylanjha
Copy link
Contributor

@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

@LewisJEllis
Copy link
Member

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);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants