Bull: Adding new job after second removal with removeRepeatable fails

Created on 4 Dec 2017  路  4Comments  路  Source: OptimalBits/bull

Code ilustrating the issue:

const Queue = require('bull');
const testQueue = new Queue('test');

testQueue.process(function(job) {
  console.log('Work, work!');
});

const init = async () => {
  await testQueue.add('myTestJob', {
    data: '1',
  }, {
    repeat: {
      cron: '* * * * *',
    },
  });

  console.log((await testQueue.getDelayed()).length); // 1

  await testQueue.removeRepeatable('myTestJob', {
    cron: '* * * * *'
  })

  console.log((await testQueue.getDelayed()).length); // 0

  await testQueue.add('myTestJob', {
    data: '2',
  }, {
    repeat: {
      cron: '*/5 * * * *',
    },
  });

  console.log((await testQueue.getDelayed()).length); // 1

  await testQueue.removeRepeatable('myTestJob', {
    cron: '*/5 * * * *'
  })

  console.log((await testQueue.getDelayed()).length); // 0

  await testQueue.add('myTestJob', {
    data: '2',
  }, {
    repeat: {
      cron: '*/5 * * * *',
    },
  });

  console.log((await testQueue.getDelayed()).length); // 0, but should be one
}

init();

As you can see, after first removal with removeRepeatable job is added just fine, but after seconde removal job is not added at all. This is very critical issue in my use case.

bug

All 4 comments

I have reproduced the bug and I understand what is causing it, however I need to figure out a good solution since it is not totally trivial.

I figured out a workaround, but waiting for proper solution. Thx.

I have a proper fix now, I will make the release tomorrow.

Thanks!

Was this page helpful?
0 / 5 - 0 ratings