taskforcesh / bullmq

BullMQ - Message Queue and Batch processing for NodeJS and Python based on Redis
https://bullmq.io
MIT License
5.95k stars 386 forks source link

[Bug]: getRepeatableJobs() gives inactive repeatable jobs along (along with active repeatable jobs) #2376

Open vraj-fyno opened 8 months ago

vraj-fyno commented 8 months ago

Version

v4.7.0

Platform

NodeJS

What happened?

Requirement

Expected

Actual

How to reproduce.

Add data along with limits

const { Queue } = require("bullmq");

const connection = {
    port: process.env.REDIS_QUEUE_PORT,
    host: process.env.REDIS_QUEUE_HOST,
    password: process.env.REDIS_QUEUE_PASSWORD || "",
};
const EVENTQ_NAME = new Queue("campaign", {
    connection,
});

let repeatable = async () => {
    const test = await EVENTQ_NAME.add(
        "dynamite",
        { color: "black" },
        {
            repeat: {
                pattern: "* * * * *",
                limit: 10,
            },
        }
    );
    console.log(test.repeatJobKey);
};

repeatable();

See the repeatable jobs after the above is consumed by a worker

const { Queue } = require("bullmq");

const connection = {
    port: process.env.REDIS_QUEUE_PORT,
    host: process.env.REDIS_QUEUE_HOST,
    password: process.env.REDIS_QUEUE_PASSWORD || "",
};
const EVENTQ_NAME = new Queue("campaign", {
    connection,
});

let repeatable = async () => {
    const repeatableJobs = await EVENTQ_NAME.getRepeatableJobs();
    console.log(repeatableJobs);
};

repeatable();

Relevant log output

[
  {
    "key": "campaign:CAPVUXP4P::Asia/Kolkata:* * * * *",
    "name": "campaign",
    "id": "CAPVUXP4P",
    "endDate": null,
    "tz": "Asia/Kolkata",
    "pattern": "* * * * *",
    "next": 1705057500000
  }
]

Code of Conduct

vraj-fyno commented 8 months ago

In the bull monitor, there is no data in the delayed queue

image
manast commented 8 months ago

Currently this works as expected, however I see it could be useful to have a feature to filter out repeatable jobs that have expired, or that they get "auto removed" after they expire.

vraj-fyno commented 8 months ago

Thanks! Yeah, it would be a great feature to have.