Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • B bull
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 175
    • Issues 175
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 9
    • Merge requests 9
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OptimalBits
  • bull
  • Issues
  • #762
Closed
Open
Issue created Oct 27, 2017 by Administrator@rootContributor

Delay isn't honored when using multiple workers

Created by: claudiopetrini

Hello, I'm using bull for waiting a specific amount of time with the delay option.

Everything works fine until there's only one worker that's processing the queue, as soon as there are multiple workers delay seems not to be honored.

Here a snippet of code of the producer:

const Queue = require('bull');

const redisConfig = {
  host: 'localhost',
  port: '6379',
  db: 2,
};

const queue = new Queue('steps', {
  redis: redisConfig,
  prefix: 'wait',
});

for (let i = 1; i <= 5; i++) {
  const wait = i * 3000;
  const options = {
    delay: wait,
    removeOnComplete: true,
    removeOnFail: true,
  };
  const data = {
    waited: wait,
  };
  queue.add(data, options)
    .then(() => {
      console.log(`ADDED ${i}`);
    })
    .catch((err) => {
      console.log(err);
    });
}

And here's a snippet of code of the workers :

const Queue = require('bull');

const redisConfig = {
  host: 'localhost',
  port: '6379',
  db: 2,
};

const queue = new Queue('steps', {
  redis: redisConfig,
  prefix: 'wait',
});

queue.process((job, done) => {
  console.log('PROCESSING', job.data);
  done();
});

When multiple workers are up jobs are received without honoring wait time, am I missing something? Thank you.

Assignee
Assign to
Time tracking