Closed Haris-Ali closed 5 months ago
There are many reasons why your approach won't work, so I will not dig into details. However, I can give you a couple of hints, first I will recommend you to use BullMQ instead (newer, more stable, better maintained), and secondly, you should be able to use the standard retry settings for a use case like this, from what you write it seems like a standard retry case with the "removeOnFail" option.
https://docs.bullmq.io/guide/workers/auto-removal-of-jobs https://docs.bullmq.io/guide/retrying-failing-jobs
Hi, I was dabbling into bull queue because I was going to incorporate it into my project. The scenario in my project is that every job can be retried once (i.e. if it fails a second time, it should be removed from the queue). The job is basically handling some API call to a third party server which may or may not respond always. Which is why I have a setInterval to check if certain time has elapsed since job started processing. I have to fail the job and send it to retry if this is the first attempt otherwise remove it/mark as failed. Below is a minimum test code for the issue I am facing. Basically, moveToFailed function takes the job into waiting state (which doesn't make sense? Should it not move to failed state?) It then retries the job once more after which no other job is being processed.
I have to manually call moveToFailed and/or moveToCompleted because of my desired functionality. If there's something I should do differently please do let me know as it is pretty essential I incorporate this feature.
I am using bull version 4.12.9