Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repeatable jobs 'every': wrong behavior #1853

Closed
xrip opened this issue Sep 11, 2020 · 4 comments
Closed

Repeatable jobs 'every': wrong behavior #1853

xrip opened this issue Sep 11, 2020 · 4 comments

Comments

@xrip
Copy link

xrip commented Sep 11, 2020

Description

Repeatable jobs with "every" parameter works wrong or have confusing documentation.

When i create job with { repeat: { every: 15 * 1000 } } params
i expect the job would be fired every 15 seconds since job created.
E.g. if it's created at 15:34:07 the job would run at 15:34:22, then 15:34:37 and so on.
But actually it would run at 15:34:15, 15:34:30, 15:34:45

Minimal, Working Test code to reproduce the issue.

const Queue = require('bull');

const myqueue = new Queue('q');

console.log(new Date, '- Adding job');

(async () => {
    // Repeat every 15 seconds
    const myJob = await myqueue.add(
        { foo: 'bar' },
        {
            jobId: 'every_15_seconds',
            repeat: {
                every: 15 * 1000,
            },
        },
    );

    myqueue.process(function(job, done) {
        console.log(new Date, '- Running job');

        done();
    });
})();
/*
Excepted result:
2020-09-14T16:28:08.884Z - Adding job
2020-09-14T16:28:23.020Z - Running job
2020-09-14T16:28:38.015Z - Running job
2020-09-14T16:28:53.008Z - Running job

Actual result:
2020-09-14T16:28:08.884Z - Adding job
2020-09-14T16:28:15.020Z - Running job
2020-09-14T16:28:30.015Z - Running job
2020-09-14T16:28:45.008Z - Running job

Looks like it runs every 15 seconds since day start, not the startDate nor time, when job was added.
 */

Bull version

3.18.0

Additional information

@xrip
Copy link
Author

xrip commented Sep 14, 2020

Example updated to be more relevant.

@manast
Copy link
Member

manast commented Sep 14, 2020

This works as designed, here you can find some background: #1239

@manast manast closed this as completed Sep 14, 2020
@wiput1999
Copy link

I'm expecting this result too. How to config for this expected result?

@xrip
Copy link
Author

xrip commented Sep 27, 2020

I've solve this by adding delayed job and reading new job when processing current job.
Works like i want. But it's not durable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants