vsivsi / meteor-job-collection

A persistent and reactive job queue for Meteor, supporting distributed workers that can run anywhere.
https://atmospherejs.com/vsivsi/job-collection
Other
388 stars 68 forks source link

UnhandledPromiseRejectionWarning when creating jobs #272

Open luixal opened 5 years ago

luixal commented 5 years ago

Hi,

I'm using a function to create jobs. When creating them like this, I have no problems at all:

startPurgeOldJobsJob: function() {
  console.log('startPurgeOldJobsJob');
  // creates job with no data:
  let job = new Job(
    jobsCollection,
    JOB_TYPES.PURGE_OLD_JOBS,
    {}
  );
  // sets repeating schedule:
  job.repeat({
    schedule: jobsCollection.later.parse.text('on the first day at 1:00')
  });
  // set retry options in case of failure:
  job.retry({
    retries: 5,
    wait: 10*60*1000,
    backoff: 'exponential'
  });
  // saves job cancelling other jobs generated for repetitions:
  job.save({cancelRepeats: true});
  // returns generated job:
  return job;
}

However, when I remove the {cancelRepeats: true} options in the .save(), I start getting this errors about UnhandledPromiseRejectionWarning like this:

(STDERR) (node:60748) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): RangeError: Maximum call stack size exceeded
(STDERR) (node:60748) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Any ideas on this issue?