bullmq: Incorrect docs regarding reusing Redis connection?

Based on docs here: https://docs.bullmq.io/guide/connections

It says to pass IORedis instance as the connection option to both worker and queue, however when I do that, I get the following error from the worker:

TypeError: client.moveToActive is not a function
    at Function.moveToActive (/home/project/node_modules/bullmq/dist/classes/scripts.js:247:37)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async Worker.moveToActive (/home/project/node_modules/bullmq/dist/classes/worker.js:135:31)

And the queue throws this when add is called:

TypeError: client.addJob is not a function
    at Function.addJob (/home/project/node_modules/bullmq/dist/classes/scripts.js:38:23)
    at Job.addJob (/home/project/node_modules/bullmq/dist/classes/job.js:323:34)
    at Function.create (/home/project/node_modules/bullmq/dist/classes/job.js:32:28)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async Queue.add (/home/project/node_modules/bullmq/dist/classes/queue.js:34:25)

Interestingly enough, if I pass the IORedis instance as the client option, then it works just fine. So am I missing something or the documentation is not correct.outdated?

BullMQ version: 1.6.6

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 17 (8 by maintainers)

Most upvoted comments

So from the quickstart guide:

import { Worker } from 'bullmq'

const worker = new Worker(queueName, async job => {
    // Will print { foo: 'bar'} for the first job
    // and { qux: 'baz' } for the second.
    console.log(job.data);
});

The second argument is the processing function. The options are the third argument to the constructor.

Try:

const myWorker = new Worker(
  "myworker",
  async job => {
    console.log("run");
  },
  { connection }
);

Error: Type ‘Redis’ is not assignable to type ‘ConnectionOptions’

on redis@^5.4.2, works after downgrading into ^5.4.1

same error bullmq@3.5.10, ioredis@5.3.0