-
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
Queue's asynchronous hooks aren't waiting to be finished! #2358
Comments
This works as designed. I cannot imagine it working any other way, these are no "hooks" as you may be familiar with other frameworks such as Angular or Vue. Bull is a distributed system and these are "events" and they are triggered concurrently since you can potentially have thousands of jobs being processed in parallel. Having said that, you are not supposed to use the events for updating database statuses and similar, that is not a robust way to design a system, you should update things inside the processor function so that you can get some guarantees that you do not get with events. I recommend you check some of the tutorials I wrote here: https://blog.taskforce.sh (they are for BullMQ but the principles can be applied for Bull too). |
@manast, Thanks for clearing out quickly, I'll update my design to process DB updates over the process. However, can you mention a few suitable use cases of using events for a similar thing because simply wrapping the processor in try-catch will handle job |
You do not need to wrap the processor in try/catch, Bull takes care of it already and will complete or fail the job depending on any exceptions thrown. |
@manast, Yes I do understand it clearly, It's just that I need to mimick all those 3 events into the processor as you've mentioned (create a log on worker start and update log status to complete/fail based on processors execution) and I can simply retain Bull's default behavior by throwing the same error that has been caught in I was just wondering about some examples where using |
Maybe you should take a look at Flows https://docs.bullmq.io/guide/flows |
Description
When the hooks are being triggered on the lifecycle change of the Job, The triggered hook isn't waiting for the callback to finish before triggering another hook.
What is happening?
Currency on lifecycle change, the next hook is being triggered without caring for previously triggered hooks! For Example:
Expected behavior
I think it really should wait for the previous hook's callback before starting the next hook if it's implemented into the design pattern. I want to know if it's really breaking change or if it is me doing things wrong. 👍
Minimal, Working Test code to reproduce the issue.
Bull version - ^4.6.2
Additional information
The text was updated successfully, but these errors were encountered: