Created by: papandreou
Background: In our bull installation we're cleaning out failed jobs after 24 hours by periodically running await queue.clean(24 * 60 * 60 * 1000, 'failed');
. Yesterday we had a big workload and ran into some fairly troublesome jobs that had to be tried multiple times, but still failed in the end. This morning I was expecting that they were still around so I could make some tweaks and retry them, but I found that they had been cleaned out despite having been attempted within the last 24 hours.
I looked into it and found that Queue#clean
always compares uses the job's timestamp
when determining whether it falls within the grace period. That feels undesirable in a situation like the above. Seems fairly easy to also have it look at when the job was last processed and when it finished, so I went ahead and implemented that.
LMK what you think