Avoid an error after a one-time scheduled job#21
Conversation
When setting a scheduled job that occurs just one time, the function was returning an error because next[1] is then undefined and .getTime() is not defined. Adding a test to bypass this error.
|
@jnkien - thanks for your PR. The code you've changed comes from https://github.com/bunkat/later/blob/master/src/core/settimeout.js, unmodified except for adding the intendedAt parameter. I would prefer to leave the logic in here as is. Can you reproduce the issue in plain later.js? If not, could you please make the fix outside of |
|
@zol - thank you for your feedback. I understand the fact that you want to keep the logic of included parts of code from I investigate the possibility of a fix outside of Then, I reproduced the issue in plain Later = Meteor.npmRequire('later');
var schedule = function(parser) {
var cronDate = '30 12 16 10 * 2014';// just change the first 4 parameters to trigger the job asap
return parser.cron(cronDate);
};
var s = schedule(Later.parse);
Later.setInterval(function(){
console.log("This is a one time scheduled job.");
return true;
}, s);
console.log('One time scheduled job @' + Later.schedule(s).next(1));I think I can simply use my own fork in my project (it will work but...) or submit a pull request to the What do you suggest? |
Enable adding scheduled jobs on-the-fly. Jobs can be saved and loaded between server restarts. A job can be run back if the date is passed. Display the next schedule time after running a job.
|
|
When setting a scheduled job that occurs just one time, the function
was returning an error because next[1] is then undefined and .getTime()
is not defined. Adding a test to bypass this error.