Skip to content


Subversion checkout URL

You can clone with
Download ZIP


onComplete not being called #35

dunxm opened this Issue · 4 comments

2 participants


I set up a very simple test program to run a few times and then used setTimeout to stop the job. However my onComplete function never seems to be called, the job is stopping though.

var cronJob = require('cron').CronJob

function cronRun() { console.log('run'); }
function cronStopped() { console.log('stopped'); }
function stopCronJob(j) { j.stop(); }

job = new cronJob('*/15 * * * * *', cronRun, cronStopped, true);
setTimeout(stopCronJob, 35000, job);

@ncb000gt ncb000gt referenced this issue from a commit
@ncb000gt Fix tests and make sure onComplete runs - GH-35.
onComplete wasn't being called correctly. While it was being passed to
the onTick calls appropriately it should have been fired when the job
was explicitly stopped or when the timer ran out, not to be run again.
This wasn't happening.

Additionally, the tests for onComplete were really bad. They were
expecting that the onTick fire off the onCompletes. That is...lacking to
say the least. This has now been fixed as well.

Signed-off-by: Nick Campbell <>

This appears to be fixed and tested at!/ncb000gt/node-cron/builds/1422446

Let me know if you see this again. I'm going to cut a new version and throw it up on npm.

@ncb000gt ncb000gt closed this

Forgot to say thank you for reporting this, so thanks! :)

The tests covering this really were pretty boneheaded... /facepalm


I can confirm that my wee test program now works. Many thanks.


Excellent. Thanks for the ticket! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.