Skip to main content

Overview

The QueueEvents class is used for listening to global events emitted by a queue. This class requires a dedicated Redis connection.

Constructor

name
string
required
The name of the queue to listen to
opts
QueueEventsOptions
Configuration options for queue events

Example

Methods

run

Manually starts the event consumption loop.
You only need to call this if you set autorun: false in the constructor options.

close

Stops consuming events and closes the Redis connection.

Events

The QueueEvents class extends EventEmitter and emits the following events:

added

Emitted when a job is created and added to the queue.
args.jobId
string
The unique identifier of the job
args.name
string
The name of the job
id
string
The event stream ID

active

Emitted when a job enters the active state.
args.jobId
string
The unique identifier of the job
args.prev
string
The previous state of the job

completed

Emitted when a job has successfully completed.
args.jobId
string
The unique identifier of the job
args.returnvalue
any
The return value of the job (JSON parsed)
args.prev
string
The previous state of the job

failed

Emitted when a job has failed.
args.jobId
string
The unique identifier of the job
args.failedReason
string
The reason or message describing why the job failed
args.prev
string
The previous state of the job

progress

Emitted when a job updates its progress.
args.jobId
string
The unique identifier of the job
args.data
number | object
The progress data

delayed

Emitted when a job is scheduled with a delay.
args.jobId
string
The unique identifier of the job
args.delay
number
The delay duration in milliseconds

waiting

Emitted when a job enters the waiting state.

waiting-children

Emitted when a job is waiting for its children to complete.

removed

Emitted when a job is removed from the queue.

drained

Emitted when the queue has drained its waiting list.

paused

Emitted when the queue is paused.

resumed

Emitted when the queue is resumed.

stalled

Emitted when a job has stalled.

retries-exhausted

Emitted when a job has exhausted its retry attempts.

duplicated

Emitted when a job is not created because a job with the same ID already exists.

deduplicated

Emitted when a job is not added because a job with the same deduplication ID exists.

cleaned

Emitted when jobs are cleaned from the queue.

error

Emitted when an error occurs in the Redis backend.

Job-Specific Events

You can also listen to events for a specific job: