Skip to content

isFailedJob

function isFailedJob<T>(job): boolean;

Defined in: packages/core/src/jobs/guards.ts:168

Type guard to check if a job has permanently failed.

A convenience helper for checking if a job exhausted all retries. Equivalent to job.status === JobStatus.FAILED but with better semantics.

Type ParameterDescription
TThe type of the job’s data payload
ParameterTypeDescription
jobJob<T>The job to check

boolean

true if the job status is 'failed'

const jobs = await monque.getJobs();
const failedJobs = jobs.filter(isFailedJob);

for (const job of failedJobs) {
  console.error(`Job ${job.name} failed: ${job.failReason}`);
  await sendAlert(job);
}