-
Notifications
You must be signed in to change notification settings - Fork 360
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
Infinite loop with day_of_week #469
Comments
Similar issue with another schedule:
It seems when the number is greater than 5, it freezes. |
It seems that setting any invalid values and
Must be stuck in a loop somehow. |
Getting the same issue. I had some code that misunderstands how day_of_week validations should be created. A test rule hash was created for the purpose of having an occurrence for every day of the second week. The hash generated was this:
The correct way to create this hash is like so:
The first hash is actually asking for occurrences for every 0th, 1st, 2nd, 3rd, 4th, 5th, and 6th Tuesday of every month. There is no 0th or 6th Tuesday of any month. When calling |
The problem is that there is no protection against rules which don't result in any occurrences within a schedule. PR #554 will add validations to catch most cases, but I expect there will always be edge cases involving combining multiple rules, such as picking months with less than 31 days and asking for the 31st day of the month. For that we will need to add some kind of infinite-loop protection, but raising an error doesn't feel right. Probably better to just return an empty schedule. |
I like this idea because it feels very "rubyish". My work around if I recall -- this was a few years ago -- was to take the hash and sanitize it. Remove any keys/indices that don't belong like a 0th Friday or 6th Sunday or something like that and then pass it along to whatever reads the hash. |
Essentially doing this makes an infinite loop:
day_of_week(monday: [0])
Full reproduction test case:
The text was updated successfully, but these errors were encountered: