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

fix(pattern): do not save offset when immediately is provided #2756

Merged
merged 2 commits into from
Sep 10, 2024

Conversation

roggervalf
Copy link
Collaborator

@roggervalf roggervalf commented Sep 4, 2024

fixes #2754

@@ -340,7 +340,11 @@ export const getNextMillis = (
});

try {
return interval.next().getTime();
if(opts.immediately){
return interval.prev().getTime();
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when immediately is provided, previous time should be provided as prevMillis

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when next getTime is returned, next delayed job won't be schedule in the first cron iteration but in the second one, so it add extra delay. In order to prevent that, this value should be less that the first millis value. Looks like returning the current time is sufficient and makes more sense as we are using immediately option, changed in last commit

@@ -65,7 +65,7 @@ export class Repeat extends QueueBase {
const hasImmediately = Boolean(
(every || pattern) && repeatOpts.immediately,
);
const offset = hasImmediately ? now - nextMillis : undefined;
const offset = (hasImmediately && every) ? now - nextMillis : undefined;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only needed when every is provided, with pattern we don't need to subtract this value as it should execute next delayed job in an specific time

Copy link
Contributor

@manast manast left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@roggervalf roggervalf merged commit a8cb8a2 into master Sep 10, 2024
10 checks passed
@roggervalf roggervalf deleted the fix-pattern-remove-offset branch September 10, 2024 12:36
github-actions bot pushed a commit that referenced this pull request Sep 10, 2024
## [5.12.15](v5.12.14...v5.12.15) (2024-09-10)

### Bug Fixes

* **metrics:** differentiate points in different minutes to be more accurate ([#2766](#2766)) (python) ([7cb670e](7cb670e))
* **pattern:** do not save offset when immediately is provided ([#2756](#2756)) ([a8cb8a2](a8cb8a2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants