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

[Bug]: Getting started documentation doesn't run #2838

Open
1 task done
llimllib opened this issue Oct 18, 2024 · 0 comments
Open
1 task done

[Bug]: Getting started documentation doesn't run #2838

llimllib opened this issue Oct 18, 2024 · 0 comments

Comments

@llimllib
Copy link

llimllib commented Oct 18, 2024

Version

5.21.0

Platform

NodeJS

What happened?

The docs say to start with:

import { Worker } from 'bullmq';

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

But that runs into this error, Worker requires a connection.

The simplest possible worker might look more like:

import { Worker } from "bullmq";
import { Redis } from "ioredis";

const connection = new Redis({ maxRetriesPerRequest: null });

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

A related note is that the documentation given in the connections docs doesn't run:

import { Queue, Worker } from "bullmq";
import IORedis from "ioredis";

const connection = new IORedis();

// Reuse the ioredis instance
const myQueue = new Queue("myqueue", { connection });
const myWorker = new Worker("myqueue", async (job) => {}, { connection });

Throws Error: BullMQ: Your redis options maxRetriesPerRequest must be null.

Tested with bullmq 5.21.0 and ioredis 5.4.1:

├─┬ [email protected]
│ └── [email protected] deduped
└── [email protected]

How to reproduce.

No response

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@llimllib llimllib added the bug Something isn't working label Oct 18, 2024
@manast manast added better docs and removed bug Something isn't working labels Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants