Skip to content

Repeatable job never gets processed sometimes #1739

@malisetti

Description

@malisetti

I have observed that sometimes a repeated job never gets handled for processing. If you get the getRepeatableJobs of the queue, sometimes(randomly happening) the next value is always less than current timestamp and both getDelayedCount and getPausedCount are 0

Minimal, Working Test code to reproduce the issue


const helloQueue = new Queue('hello-queue', 'redis://127.0.0.1:6379');

(async () => {
    helloQueue.process(async (job, done) => {
        console.log('hello world');
        done();
    });

    const c = await helloQueue.add(null, {
        repeat: { cron: '*/2 * * * *' },
    });

    setInterval(() => {
        helloQueue.getDelayedCount().then(j => console.log(j));
        helloQueue.getPausedCount().then(j => console.log(j));
        helloQueue.getRepeatableJobs().then(ji => console.log(ji));
        console.log(new Date().getTime());
    }, 10 * 1000);
})();

Output:

current timestamp: 1589657543148
[
  {
    key: '__default__::::*/2 * * * *',
    name: '__default__',
    id: null,
    endDate: null,
    tz: null,
    cron: '*/2 * * * *',
    every: null,
    next: 1589657520000
  }
]
getDelayedCount: 0
getPausedCount: 0

Create a hello world cron job which prints to console every 2 minutes

Bull version: "bull": "^3.13.0"

Additional information

next timestamp is lower than the current timestamp and the hello world is not printed every 2 mins

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions