How to wait for a queue to be idle for a serverless functions? #3072
-
I'm using BullMQ with serverless functions. How can I ensure all tasks in a queue to finish (either completed or failed) before shutting down? Is there a Cheers. |
Beta Was this translation helpful? Give feedback.
Answered by
roggervalf
Feb 13, 2025
Replies: 1 comment 3 replies
-
hi @knthmn, since v5.40.1 it should be safe to close your workers and they will wait for all pending jobs before closing entirely |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Now I see what you meant. Yes, when closing, workers won't pick new jobs. We have this event https://api.docs.bullmq.io/interfaces/v5.WorkerListener.html#drained, but take in count that any job apart of waiting ones are not considered by this event.