taskforcesh / bullmq

BullMQ - Message Queue and Batch processing for NodeJS and Python based on Redis
https://bullmq.io
MIT License
6.19k stars 405 forks source link

[Bug]: upsertJobScheduler does not publish data #2915

Closed AhmedSKBHL closed 2 hours ago

AhmedSKBHL commented 2 hours ago

Version

v5.27.0

Platform

NodeJS

What happened?

Job.data field is an empty object when job is received by processor

How to reproduce.

await queue.upsertJobScheduler( jobId, { pattern: '/20 ' }, data, );

Relevant log output

No response

Code of Conduct

AhmedSKBHL commented 2 hours ago

sorry, it was an error from my side

manast commented 2 hours ago

It works, but you need to pass the correct arguments:

  it("should return a valid job with the job's options and data passed as the job template", async function () {
    const repeatOpts = {
      every: 1000,
    };

    const job = await queue.upsertJobScheduler('test', repeatOpts, {
      data: { foo: 'bar' },
    });

    expect(job).to.be.ok;
    expect(job!.data.foo).to.be.eql('bar');
    expect(job!.opts.repeat!.every).to.be.eql(1000);
  });

Your code above should have given you a compiler error ...

AhmedSKBHL commented 1 hour ago

@manast, yeah my bad the issue is on my side, sorry i'm working on legacy project, there's a layer on the top of the queue that hided the error, thanks a lot for fast reaction