Is there a way to end a job that is taking too long like a timeout? #1378
-
I'm having trouble understanding if there's a way to timeout a job. Use case: a job that should take a second or two is taking longer than expected. Maybe a GET request to an api is not responding. Maybe some infinite loop is happening. Maybe it got stuck somewhere and will never finish. I'd want to fail the job and keep it from proceeding, maybe undo what it already did. Does a timeout exists in bullmq? I looked through the repo and it looked like this existed in bull but not bullmq, but I wasn't sure. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Since promises do not support cancellation it is not easy to implement a correct generic solution. You could implement your own TTL in the job by implementing your own cancel/cleanup mechanism and then reject the promise with some timeout specific code. Otherwise the solution we currently offer is in the Pro version using Observables (which not always is easy either since observables are not ubiquitous in node): https://docs.bullmq.io/bullmq-pro/observables/cancelation |
Beta Was this translation helpful? Give feedback.
Since promises do not support cancellation it is not easy to implement a correct generic solution. You could implement your own TTL in the job by implementing your own cancel/cleanup mechanism and then reject the promise with some timeout specific code. Otherwise the solution we currently offer is in the Pro version using Observables (which not always is easy either since observables are not ubiquitous in node): https://docs.bullmq.io/bullmq-pro/observables/cancelation