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

[Is this a Bug or a Feature]: A queue's default job options not persistent #2740

Closed
1 task done
smagdziarz opened this issue Aug 27, 2024 · 2 comments
Closed
1 task done

Comments

@smagdziarz
Copy link

Version

v5.12.5

Platform

NodeJS

What happened?

I created a Queue with some default job options, a Worker for this queue, and a Job. This works fine.

Then, using a separate script, I wanted to add another job to the same queue, so that it would get processed by the existing worker. It does, but the default job options assigned initially to the queue are ignored.

I expected the original options to be obeyed, after all the documentation states: When you instantiate a Queue, BullMQ will just upsert a small "meta-key", so if the queue existed before it will just pick it up and you can continue adding jobs to it..

At the same time, one of your developers stated that the queue's defaultJobOptions are not persisted.

But why? This would mean that the default options are, well... not always default. This seems inconsistent to me, or perhaps I'm getting something wrong?

How to reproduce.

Main file: file1.ts

const queue = new Queue(
  "my-queue",
  {
    connection,
    defaultJobOptions: {
      delay: 5000
    }
  },
);

new Worker(
  "my-queue",
  async (job) => {
    console.log(job.name);
  },
  {
    connection
  }
);

const job = queue.add("my-regular-job", {}); // this job will get executed after 5 seconds, this is fine

Second file: file2.ts

const queue = new Queue(
  "my-queue",
  {
    connection,
  }
);

const job = queue.add("my-external-test-job", {}); // this job gets executed immediately, ignoring the default job options set in file1

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@smagdziarz smagdziarz added the bug Something isn't working label Aug 27, 2024
@manast manast removed the bug Something isn't working label Aug 27, 2024
@manast
Copy link
Contributor

manast commented Aug 27, 2024

The job default options are per job added by a specific queue instance and not global.

@smagdziarz
Copy link
Author

Oh, ok, I guess that wasn't clear to me that the defaultJobOptions are Queue-instance specific, and not Queue specific.

Thanks for the explanation.

@github-staff github-staff deleted a comment from mengyanshou Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants