bullmq - v5.52.2
    Preparing search index...

    Interface QueueEventsListener

    interface QueueEventsListener {
        active: (args: { jobId: string; prev?: string }, id: string) => void;
        added: (args: { jobId: string; name: string }, id: string) => void;
        cleaned: (args: { count: string }, id: string) => void;
        completed: (
            args: { jobId: string; prev?: string; returnvalue: string },
            id: string,
        ) => void;
        debounced: (
            args: { debounceId: string; jobId: string },
            id: string,
        ) => void;
        deduplicated: (
            args: {
                deduplicatedJobId: string;
                deduplicationId: string;
                jobId: string;
            },
            id: string,
        ) => void;
        delayed: (args: { delay: number; jobId: string }, id: string) => void;
        drained: (id: string) => void;
        duplicated: (args: { jobId: string }, id: string) => void;
        error: (args: Error) => void;
        failed: (
            args: { failedReason: string; jobId: string; prev?: string },
            id: string,
        ) => void;
        "ioredis:close": () => void;
        paused: (args: object, id: string) => void;
        progress: (args: { data: JobProgress; jobId: string }, id: string) => void;
        removed: (args: { jobId: string; prev: string }, id: string) => void;
        resumed: (args: object, id: string) => void;
        "retries-exhausted": (
            args: { attemptsMade: string; jobId: string },
            id: string,
        ) => void;
        stalled: (args: { jobId: string }, id: string) => void;
        waiting: (args: { jobId: string; prev?: string }, id: string) => void;
        "waiting-children": (args: { jobId: string }, id: string) => void;
    }

    Hierarchy (View Summary)

    Index

    Properties

    active: (args: { jobId: string; prev?: string }, id: string) => void

    Listen to 'active' event.

    This event is triggered when a job enters the 'active' state, meaning it is being processed.

    Type declaration

      • (args: { jobId: string; prev?: string }, id: string): void
      • Parameters

        • args: { jobId: string; prev?: string }

          An object containing details about the job that became active.

          • jobId: The unique identifier of the job that entered the active state.
          • prev: The previous state of the job before it became active (e.g., 'waiting'), if applicable.
        • id: string

          The identifier of the event.

        Returns void

    added: (args: { jobId: string; name: string }, id: string) => void

    Listen to 'added' event.

    This event is triggered when a job is created and added to the queue.

    Type declaration

      • (args: { jobId: string; name: string }, id: string): void
      • Parameters

        • args: { jobId: string; name: string }

          An object containing details about the newly added job.

          • jobId - The unique identifier of the job that was added.
          • name - The name of the job, typically indicating its type or purpose.
        • id: string

          The identifier of the event.

        Returns void

    cleaned: (args: { count: string }, id: string) => void

    Listen to 'cleaned' event.

    This event is triggered when jobs are cleaned (e.g., removed) from the queue, typically via a cleanup method.

    Type declaration

      • (args: { count: string }, id: string): void
      • Parameters

        • args: { count: string }

          An object containing the count of cleaned jobs.

          • count - The number of jobs that were cleaned, represented as a string due to Redis serialization.
        • id: string

          The identifier of the event.

        Returns void

    completed: (
        args: { jobId: string; prev?: string; returnvalue: string },
        id: string,
    ) => void

    Listen to 'completed' event.

    This event is triggered when a job has successfully completed its execution.

    Type declaration

      • (args: { jobId: string; prev?: string; returnvalue: string }, id: string): void
      • Parameters

        • args: { jobId: string; prev?: string; returnvalue: string }

          An object containing details about the completed job.

          • jobId - The unique identifier of the job that completed.
          • returnvalue - The return value of the job, serialized as a string.
          • prev - The previous state of the job before completion (e.g., 'active'), if applicable.
        • id: string

          The identifier of the event.

        Returns void

    debounced: (args: { debounceId: string; jobId: string }, id: string) => void

    Listen to 'debounced' event.

    Type declaration

      • (args: { debounceId: string; jobId: string }, id: string): void
      • Parameters

        • args: { debounceId: string; jobId: string }

          An object containing details about the debounced job.

          • jobId - The unique identifier of the job that was debounced.
          • debounceId - The identifier used to debounce the job, preventing duplicate processing.
        • id: string

          The identifier of the event.

        Returns void

    Use the 'deduplicated' event instead.

    This event is triggered when a job is debounced because a job with the same debounceId still exists.

    deduplicated: (
        args: {
            deduplicatedJobId: string;
            deduplicationId: string;
            jobId: string;
        },
        id: string,
    ) => void

    Listen to 'deduplicated' event.

    This event is triggered when a job is not added to the queue because a job with the same deduplicationId already exists.

    Type declaration

      • (
            args: {
                deduplicatedJobId: string;
                deduplicationId: string;
                jobId: string;
            },
            id: string,
        ): void
      • Parameters

        • args: { deduplicatedJobId: string; deduplicationId: string; jobId: string }

          An object containing details about the deduplicated job.

          • jobId - The unique identifier of the job that was attempted to be added.
          • deduplicationId - The deduplication identifier that caused the job to be deduplicated.
          • deduplicatedJobId - The unique identifier of the existing job that caused the deduplication.
        • id: string

          The identifier of the event.

        Returns void

    delayed: (args: { delay: number; jobId: string }, id: string) => void

    Listen to 'delayed' event.

    This event is triggered when a job is scheduled with a delay before it becomes active.

    Type declaration

      • (args: { delay: number; jobId: string }, id: string): void
      • Parameters

        • args: { delay: number; jobId: string }

          An object containing details about the delayed job.

          • jobId - The unique identifier of the job that was delayed.
          • delay - The delay duration in milliseconds before the job becomes active.
        • id: string

          The identifier of the event.

        Returns void

    drained: (id: string) => void

    Listen to 'drained' event.

    This event is triggered when the queue has drained its waiting list, meaning there are no jobs in the 'waiting' state. Note that there could still be delayed jobs waiting their timers to expire and this event will still be triggered as long as the waiting list has emptied.

    Type declaration

      • (id: string): void
      • Parameters

        • id: string

          The identifier of the event.

        Returns void

    duplicated: (args: { jobId: string }, id: string) => void

    Listen to 'duplicated' event.

    This event is triggered when a job is not created because a job with the same identifier already exists.

    Type declaration

      • (args: { jobId: string }, id: string): void
      • Parameters

        • args: { jobId: string }

          An object containing the job identifier.

          • jobId - The unique identifier of the job that was attempted to be added.
        • id: string

          The identifier of the event.

        Returns void

    error: (args: Error) => void

    Listen to 'error' event.

    This event is triggered when an error in the Redis backend is thrown.

    failed: (
        args: { failedReason: string; jobId: string; prev?: string },
        id: string,
    ) => void

    Listen to 'failed' event.

    This event is triggered when a job fails by throwing an exception during execution.

    Type declaration

      • (args: { failedReason: string; jobId: string; prev?: string }, id: string): void
      • Parameters

        • args: { failedReason: string; jobId: string; prev?: string }

          An object containing details about the failed job.

          • jobId - The unique identifier of the job that failed.
          • failedReason - The reason or message describing why the job failed.
          • prev - The previous state of the job before failure (e.g., 'active'), if applicable.
        • id: string

          The identifier of the event.

        Returns void

    "ioredis:close": () => void

    Listen to 'ioredis:close' event.

    This event is triggered when ioredis is closed.

    paused: (args: object, id: string) => void

    Listen to 'paused' event.

    This event is triggered when the queue is paused, halting the processing of new jobs.

    Type declaration

      • (args: object, id: string): void
      • Parameters

        • args: object

          An empty object (no additional data provided).

        • id: string

          The identifier of the event.

        Returns void

    progress: (args: { data: JobProgress; jobId: string }, id: string) => void

    Listen to 'progress' event.

    This event is triggered when a job updates its progress via the Job#updateProgress() method, allowing progress or custom data to be communicated externally.

    Type declaration

      • (args: { data: JobProgress; jobId: string }, id: string): void
      • Parameters

        • args: { data: JobProgress; jobId: string }

          An object containing the job identifier and progress data.

          • jobId - The unique identifier of the job reporting progress.
          • data - The progress data, which can be a number (e.g., percentage) or an object with custom data.
        • id: string

          The identifier of the event.

        Returns void

    removed: (args: { jobId: string; prev: string }, id: string) => void

    Listen to 'removed' event.

    This event is triggered when a job is manually removed from the queue.

    Type declaration

      • (args: { jobId: string; prev: string }, id: string): void
      • Parameters

        • args: { jobId: string; prev: string }

          An object containing details about the removed job.

          • jobId - The unique identifier of the job that was removed.
          • prev - The previous state of the job before removal (e.g., 'active' or 'waiting').
        • id: string

          The identifier of the event.

        Returns void

    resumed: (args: object, id: string) => void

    Listen to 'resumed' event.

    This event is triggered when the queue is resumed, allowing job processing to continue.

    Type declaration

      • (args: object, id: string): void
      • Parameters

        • args: object

          An empty object (no additional data provided).

        • id: string

          The identifier of the event.

        Returns void

    "retries-exhausted": (
        args: { attemptsMade: string; jobId: string },
        id: string,
    ) => void

    Listen to 'retries-exhausted' event.

    This event is triggered when a job has exhausted its maximum retry attempts after repeated failures.

    Type declaration

      • (args: { attemptsMade: string; jobId: string }, id: string): void
      • Parameters

        • args: { attemptsMade: string; jobId: string }

          An object containing details about the job that exhausted retries.

          • jobId - The unique identifier of the job that exhausted its retries.
          • attemptsMade - The number of retry attempts made, represented as a string (due to Redis serialization).
        • id: string

          The identifier of the event.

        Returns void

    stalled: (args: { jobId: string }, id: string) => void

    Listen to 'stalled' event.

    This event is triggered when a job moves from 'active' back to 'waiting' or 'failed' because the processor could not renew its lock, indicating a potential processing issue.

    Type declaration

      • (args: { jobId: string }, id: string): void
      • Parameters

        • args: { jobId: string }

          An object containing the job identifier.

          • jobId - The unique identifier of the job that stalled.
        • id: string

          The identifier of the event.

        Returns void

    waiting: (args: { jobId: string; prev?: string }, id: string) => void

    Listen to 'waiting' event.

    This event is triggered when a job enters the 'waiting' state, indicating it is queued and awaiting processing.

    Type declaration

      • (args: { jobId: string; prev?: string }, id: string): void
      • Parameters

        • args: { jobId: string; prev?: string }

          An object containing details about the job in the waiting state.

          • jobId - The unique identifier of the job that is waiting.
          • prev - The previous state of the job before entering 'waiting' (e.g., 'stalled'), if applicable.
        • id: string

          The identifier of the event.

        Returns void

    "waiting-children": (args: { jobId: string }, id: string) => void

    Listen to 'waiting-children' event.

    This event is triggered when a job enters the 'waiting-children' state, indicating it is waiting for its child jobs to complete.

    Type declaration

      • (args: { jobId: string }, id: string): void
      • Parameters

        • args: { jobId: string }

          An object containing the job identifier.

          • jobId - The unique identifier of the job waiting for its children.
        • id: string

          The identifier of the event.

        Returns void