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

Fixed skipImmediate option in .every #861

Conversation

@erics2783
Copy link
Contributor

erics2783 commented Sep 19, 2019

Fixes #610

The problem was that .every indirectly makes two calls to computeNextRunAt. Here is what was happening:

  1. .every() calls .repeatEvery()
  2. .repeatEvery() sets lastRunAt to now
  3. .repeatEvery() calls .computeNextRunAt() resulting in nextRunAt being now + interval.
  4. .repeatEvery() resets lastRunAt to undefined
  5. .every() then immediately calls .computeNextRunAt() with lastRunAt === undefined resulting in nextRunAt being set to now (without the interval)

I changed .repeatEvery() to call .computeNextRunAt() exactly once whether skipImmediate is true or not and removed the call from .every() altogether.

Copy link
Member

simison left a comment

Good catch!

Thank you for jumping in to fix it.

@simison simison added the bug label Nov 24, 2019
@simison simison merged commit 57c96da into agenda:master Nov 24, 2019
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
security/snyk - package.json (agenda) No manifest changes detected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.