diff --git a/clean_failed_job_stacks.js b/clean_failed_job_stacks.js index 393f8cd..f7f9bbc 100644 --- a/clean_failed_job_stacks.js +++ b/clean_failed_job_stacks.js @@ -49,7 +49,7 @@ forEach(args, async (name, index) => { const jobs = await queue.getFailed() const retriedJobCount = await reduce(jobs, async (count, job) => { - if (job.attemptsMade <= job.opts.attempts) { + if (!job || typeof job !== 'object' || job.attemptsMade <= job.opts.attempts) { return count } const { id, data, opts } = job diff --git a/retry_failed_jobs.js b/retry_failed_jobs.js index 71601c5..eb47966 100644 --- a/retry_failed_jobs.js +++ b/retry_failed_jobs.js @@ -49,7 +49,7 @@ forEach(args, async (name, index) => { const jobs = await queue.getFailed() const retriedJobCount = await reduce(jobs, async (count, job) => { - if (job.attemptsMade > MAX_FAILED_COUNT) { + if (!job || typeof job !== 'object' || job.attemptsMade > MAX_FAILED_COUNT) { return count } try {