Long Nguyen
Long Nguyen

Reputation: 93

Bull queue not processing simple job

I'm completely new to Bull queue and I have a decent understanding of JavaScript. I am trying to get the following example to work:

const Queue = require('bull')

const myFirstQueue = new Queue('my-first-queue');

myFirstQueue.process(async (job, done) => {
  await doSomething(job.data);
  done();
});

const doSomething = data => {
  return new Promise((resolve, reject) => {
    return resolve(data);
  });
};

myFirstQueue.on('completed', (job, result) => {
  log.debug(`Job completed with result ${job}`);
});

(async function ad() {
  const job = await myFirstQueue.add({
  foo: 'bar',
});
})();

The error I'm getting is:

\node_modules\ioredis\built\redis\event_handler.js:177
self.flushQueue(new errors_1.MaxRetriesPerRequestError(maxRetriesPerRequest));
                ^
            

MaxRetriesPerRequestError: Reached the max retries per request limit (which is 20). Refer to "maxRetriesPerRequest" option for details.
    at Socket.<anonymous> (...\node_modules\ioredis\built\redis\event_handler.js:177:37)
    at Object.onceWrapper (node:events:652:26)
    at Socket.emit (node:events:537:28)
    at TCP.<anonymous> (node:net:747:14)

Based off the error I'm getting it seems like the queue cannot process this job at all and I'm not sure why I'm getting this error. I am running the script with the command node fileName.js in the correct directory. I can run other JavaScript files fine that are even more complex than this.

EDIT: Edited code to reflect changes from comments, still have the same error.

Upvotes: 3

Views: 4498

Answers (1)

Mahesh M
Mahesh M

Reputation: 21

Need to add redis URL for connection, because bull uses redis for storing queue data.

const myFirstQueue = new Queue('my-first-queue','redis-url');

Upvotes: 1

Related Questions