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

backoffStrategies not working #639

Closed
koiszzz opened this issue Jul 14, 2021 · 2 comments
Closed

backoffStrategies not working #639

koiszzz opened this issue Jul 14, 2021 · 2 comments

Comments

@koiszzz
Copy link

koiszzz commented Jul 14, 2021

I have met a problem when using bullmq v1.39.0 . When set backStrategies in worker , the job added in queue got stuck in state delayed and never came into actived again.

const worker3 = new Worker('test3', async job => {
    console.log(`${job.name} # ${job.id} running`);
    console.log(`attemptMade: ${job.attemptsMade}`)
    throw new Error('some thing wrong');
}, {
    settings: {
        backoffStrategies: {
            jitter(attempts) {
                console.log('attempt:' + attempts);
                return 3000
            }
        }
    }
});

worker3.on('failed', (job, error) => {
    console.log(`${job.name} # ${job.id} failed`);
});
worker3.on('drained', async () => {
    console.log('worker 3 drained');
    const delayed = await queue3.getJobs(['delayed']);
    console.log('delayed jobs: ' + delayed.map(j => j.id).join(','));
});
const queue3 = new Queue('test3', {

});

(async () => {
    await queue3.add('local-test-de', {
        data: 1,
    }, {
        attempts: 3,
        backoff: {type: 'jitter'}
    });
    await queue3.add('local-test-ex', {
        data: 1
    }, {
        attempts: 3,
        backoff: {
            type: 'exponential',
            delay: 2
        }
    });
})();

It seems that when the delay of backoff setting setted bigger than 0. The job will stuck

@manast
Copy link
Contributor

manast commented Jul 15, 2021

Do you have a QueueScheduler also running? It is needed for delayed jobs. https://docs.bullmq.io/guide/queuescheduler

@koiszzz
Copy link
Author

koiszzz commented Jul 16, 2021

Thanks. The docs of retring failing job just mention QueueScheduler one time. I didn't notice that. Maybe It could add some example schedule code on retring job page . @manast

@koiszzz koiszzz closed this as completed Jul 16, 2021
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

2 participants