-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[BUG] Job.moveToFailed does not emit 'failed' event #1104
Comments
Can you provide a test code that reproduces the issue? |
@manast sorry about that, I have updated the original post |
The problem here is that you are both defining a process function and moving to fail manually. What probably happens is that it gets processed before the call to |
Processing is definitely not finished in my actual code when I do this; job still running. Also I checked the code and here is where the event is emitted. if you check |
If you remove this code it will work:
|
Yes, you are missing that the failed event is emitted from the LUA script |
@manast , ah I see, although i checked here and I still do not see the event emission! Can you please point out where exactly it happens? So, just to clarify here, If the job is in process, can I |
If the job is in process you cannot call |
Thanks for your patience. The whole flow is not very clear to me yet but I have been doing the following in
Are you saying that calling The result of the above is that the job (even while in progress) is indeed moved to failed state with failed reason |
I don't know, it must be debugged in order to be fully understood. But basically, you are calling a method that the queue is also calling, which is not good. |
btw, you can use redis command |
I will run a few debug tests with monitor and get back to you. |
@manast , after plenty of runs, i still don't think that the event is emitted anywhere else other than in |
So is the correct way to move a job to failed to return an error from the job process function? I wasn't clear either on exactly how to move jobs to the failed state and was trying to do it by calling |
@tommyc38 i think yes. Something like that: try {
// code that is run by your job
} catch (e) {
return Promise.reject(new Error(`${e}`));
} This will move the job to the failed queue. |
Thanks a lot. This worked for me :) |
Hey @tommyc38 |
Description
Just wanted to report in case it's not known already that when I use
job.moveToFailed
nofailed
event is emitted. It would be nice if it did.From what I checked only
queue.js
will emit the event after the method is called but I think the job object should do that instead.Minimal, Working Test code to reproduce the issue.
Bull version
I am using Node.js v6.9.1 with bull v3.4.8 and redis-server v3.0.7
Thank you for your time.
The text was updated successfully, but these errors were encountered: