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.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
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:- No pending dependencies: The parent is moved to wait status and may be processed
- 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:src/classes/job.ts:692:
Remove Child Dependency
Remove a child dependency relationship while the child is still unfinished:src/classes/job.ts:631:
Bulk Removal
Remove multiple jobs at once:Remove Events
Listen for removal events:Best Practices
Set Retention Policies
Set Retention Policies
Use
removeOnComplete and removeOnFail to manage queue size:Clean Regularly
Clean Regularly
Set up periodic cleaning:
Handle Removal Errors
Handle Removal Errors
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
