Skip to main content

Overview

Sometimes it’s necessary to remove a job from the queue, such as when a job contains bad data or is no longer needed.
Locked jobs (in active state) cannot be removed. An error will be thrown if you attempt to remove a locked job.
From src/classes/job.ts:668:

Automatic Removal

You can configure jobs to be automatically removed when they complete or fail:

Remove on Complete

Remove on Fail

From src/interfaces/base-job-options.ts:46:

Removing Jobs with Parent

When removing a job that has a parent job in a flow:

Child Job Removal

There are two possible cases:
  1. No pending dependencies: The parent is moved to wait status and may be processed
  2. Pending dependencies remain: The parent stays in waiting-children status
If the child is in completed state when removed, processed values will be kept in the parent’s processed hset.

Parent Job Removal

When removing a parent job with pending dependencies:
From src/classes/job.ts:692:
If any child job is locked (active), the deletion process will be stopped.

Remove Child Dependency

Remove a child dependency relationship while the child is still unfinished:
From src/classes/job.ts:631:

Bulk Removal

Remove multiple jobs at once:

Remove Events

Listen for removal events:

Best Practices

Use removeOnComplete and removeOnFail to manage queue size:
Set up periodic cleaning:
Gracefully handle locked job errors:

When to Remove Jobs

Bad Data

Remove jobs with invalid or corrupted data that cannot be processed

Cancelled Operations

Remove jobs when the user cancels the requested operation

Duplicate Jobs

Remove older duplicate jobs when newer versions exist

Expired Jobs

Remove jobs that are no longer relevant due to time constraints

API Reference

View the Remove API Reference