Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.every() Jobs Being Repeated #70

Closed
Albert-IV opened this issue Jun 10, 2014 · 6 comments
Closed

.every() Jobs Being Repeated #70

Albert-IV opened this issue Jun 10, 2014 · 6 comments

Comments

@Albert-IV
Copy link
Collaborator

I know this isn't the most helpful issue opened, but after the last update pushed to npm I am seeing daily jobs get ran every few hours.

I'm going to sit down tomorrow and get some test cases going, but just a heads up that something is up.

@Albert-IV
Copy link
Collaborator Author

Alrighty, I got a test-case that shows what happens.

It looks like we're not checking the last ran date when running jobs going through the .every() command.

A simple example use-case:

var connStr = 'mongodb://localhost/testingmctesterson';
var Agenda = require('agenda');

var agenda = new Agenda({db: { address: connStr } });

agenda.define('5 minutes job', function(job, done) {
  console.log("Running 5 minutes job");
  done();
});

agenda.define('10 minutes job', function(job, done) {
  console.log("Running 10 minutes job");
  done();
});

agenda.define('once a day job', function(job, done) {
  console.log('ONCE A DAY RUNNING');
  done();
});

agenda.every('5 minutes', '5 minutes job');
agenda.every('10 minutes', '10 minutes job');
agenda.every('0 5 * * 1-5', 'once a day job');

agenda.start();

If you use 0.6.13 everything works as expected. You are able to run the script, Ctrl-C out and re-run without the jobs being ran again.

If you use the latest version (0.6.14), these jobs will be re-ran every time you start the process, regardless if the lastRunAt field is set or not (I've confirmed that it is being set as expected).

I noticed this was an issue after seeing daily jobs get reran at random intervals. Let me know if you need me to explain further.

@rschmukler
Copy link
Collaborator

Thanks for reporting. Fixed in 0.6.15.

@Albert-IV
Copy link
Collaborator Author

Awesome, thanks for the quick fix!

@fiznool
Copy link
Contributor

fiznool commented Jun 11, 2014

@droppedonjapan sorry this was my fault, introduced with my PR #69. I hope it didn't cause you too many problems. That's what you get for refactoring code willy nilly - I shall be more careful next time...!

@Albert-IV
Copy link
Collaborator Author

@fiznool Not a problem! I'm only using it for emailing aggregate stats out, so it wasn't too much of an issue. 👍

@fiznool
Copy link
Contributor

fiznool commented Jun 11, 2014

@droppedonjapan in that case I'm glad you found it first!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants