0

I am trying to create a time in milliseconds to pass it to delay using bull queue. I can correctly get time for the processing of the job, but somehow the job is not being called at a specific time. Some time it take more than 30 or 45 seconds to process the job from it's actual start of time.

for example if delay time is for 2 minutes. it execute in 2 minutes and 45 seconds. I am unable to find the reason. I want it to run only at 2 minutes. Below is my code

const startTime = moment().tz(timeZone).set('second', 0).valueOf();
const endTime = moment(time)
      .subtract(timeToSubtract, 'minutes')
      .tz(timeZone)
      .set('second', 0)
      .valueOf();
const scheduleTime = endTime - startTime

this.queue.add(
     'test-queue',
      {
        mesage,
      },
      {
        delay: scheduleTime,
        removeOnComplete: true,
      }
    );
JN_newbie
  • 5,492
  • 14
  • 59
  • 97
  • delay: number - An amount of time (milliseconds) to wait until this job can be processed. Note that for accurate delays, both server and clients should have their clocks synchronized. – farzanmanafi Apr 14 '22 at 16:41

0 Answers0