-
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
TTL for job in active queue #1504
Comments
Hi! Basically execution timeout is achieved with timeout option, see JobOpts description here: https://github.com/OptimalBits/bull/blob/develop/REFERENCE.md#queueadd But hitting timeout doesn't mean your processing procedure would somehow be interrupted. Bull just registers job promise rejection callback with setTimeout(), and that's all. If you have a long-living loop in your processor it'd be better to check for timeout manually on each iteration and explicitly exit. There's also a possibility to execute jobs in child node process (https://github.com/OptimalBits/bull/blob/develop/docs/README.md#sandboxed-processors). |
Actually there is no long-living loop but the jobs get stuck in active state even there is no error and the jobs are processed. I am not sure exactly right now why is it happening. So the time out will put it in failed queue? |
Yes, a working example
Output
The job's As you can see, Bull fails the job while the callback is still executes; result is ignored then even if it completes successfully. |
Thanks for the help! Can you help me with the problem which leads me to use timeouts? The queue gets stuck with some job in active state and the waiting queue starts piling up |
The debugging in particular cases may be quite tricky, depending on what you're doing in process callback. Are you using async callback as in my example or call done() once work is completed? Anyway, the general advice in to add more logging to your procedure.. most likely a promise getting abandoned somewhere (ie neither reject not resolve is called). |
I am calling done() when the process is completed |
I guess something goes wrong and your procedure fails before done() is called. The error is swallowed for some reason. Try to wrap your callback code with try-catch
|
I will try that will follow back if it solves our problem. Thanks a lot for the quick response really appreciated @stansv 👏 |
Right now it is working fine for us. So I would proceed and close the issue if there is any further help needed will reopen it. Thanks! 😄 |
How can I specify TTL for a job? I tried to look through the docs but couldn't find anything related to it though I read that bull has this feature. So that if it stays in active state for the specified time it terminates automatically.
I stumbled upon this as the processor stops processing the jobs suddenly and starts working after restart. There is no log or error thrown but the processor gets stuck and jobs start piling in waiting queue.
Bull version
v3.11
The text was updated successfully, but these errors were encountered: