-
Notifications
You must be signed in to change notification settings - Fork 626
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
"0 1 30 3 *" creates infinite loop #919
Comments
Attached the debugger and tried to see what's going on. Turns out that it gets "stuck" in Added a console.log to see the dates that it was generating. Here's the list: 2025-03-30T00:00:00.000+00:00 86400000
2025-03-30T02:00:00.000+01:00 90000000
2025-03-30T03:00:00.000+01:00 93600000
2025-03-30T04:00:00.000+01:00 97200000
2025-03-30T05:00:00.000+01:00 100800000
2025-03-30T06:00:00.000+01:00 104400000
2025-03-30T07:00:00.000+01:00 108000000
2025-03-30T08:00:00.000+01:00 111600000
2025-03-30T09:00:00.000+01:00 115200000
2025-03-30T10:00:00.000+01:00 118800000
2025-03-30T11:00:00.000+01:00 122400000
2025-03-30T12:00:00.000+01:00 126000000
2025-03-30T13:00:00.000+01:00 129600000
2025-03-30T14:00:00.000+01:00 133200000
2025-03-30T15:00:00.000+01:00 136800000
2025-03-30T16:00:00.000+01:00 140400000
2025-03-30T17:00:00.000+01:00 144000000
2025-03-30T18:00:00.000+01:00 147600000
2025-03-30T19:00:00.000+01:00 151200000
2025-03-30T20:00:00.000+01:00 154800000
2025-03-30T21:00:00.000+01:00 158400000
2025-03-30T22:00:00.000+01:00 162000000
2025-03-30T23:00:00.000+01:00 165600000
2025-03-30T00:00:00.000+00:00 86400000 <----- WE'RE BACK TO SAME DATE
2025-03-30T02:00:00.000+01:00 90000000
2025-03-30T03:00:00.000+01:00 93600000
2025-03-30T04:00:00.000+01:00 97200000
2025-03-30T05:00:00.000+01:00 100800000
2025-03-30T06:00:00.000+01:00 104400000
2025-03-30T07:00:00.000+01:00 108000000
2025-03-30T08:00:00.000+01:00 111600000
2025-03-30T09:00:00.000+01:00 115200000
2025-03-30T10:00:00.000+01:00 118800000
2025-03-30T11:00:00.000+01:00 122400000
2025-03-30T12:00:00.000+01:00 126000000
2025-03-30T13:00:00.000+01:00 129600000
2025-03-30T14:00:00.000+01:00 133200000
2025-03-30T15:00:00.000+01:00 136800000
2025-03-30T16:00:00.000+01:00 140400000
2025-03-30T17:00:00.000+01:00 144000000
2025-03-30T18:00:00.000+01:00 147600000
2025-03-30T19:00:00.000+01:00 151200000
2025-03-30T20:00:00.000+01:00 154800000
2025-03-30T21:00:00.000+01:00 158400000
2025-03-30T22:00:00.000+01:00 162000000
2025-03-30T23:00:00.000+01:00 165600000 Unfortunately I don't have enough knowledge about lib internals to solve this issue. @sheerlox can you take a look at this? |
we rely on Luxon for most of our international date/time support so it's possible this is due to Luxon not handling that time period correctly |
Found the bug, PR on the way. Sorry for the delay 😓 |
I've been running more tests to confirm I found the issue, and this bug actually affects to all time zones. |
…ward jump (#938) ## Description Removes a superfluous `+ 1` modifying the behavior unexpectedly. Using the debugger I've located the bug to this instruction, and it can easily be confirmed that this `+ 1` is the issue, since `date.month` & `this.month` are both indexed starting from `1` (and not `0`). Not sure how long this bug has been around, but it was [already present when we aligned with the UNIX standard](https://github.com/kelektiv/node-cron/pull/667/files#diff-c14c2dca8456f15417b39cfbd9758009f8eb4f3a190a415768d6e4ae6ae9dceeL473-L477). ## Related Issue Fixes #919. ## Motivation and Context Fixes an infinite loop when a cron expression only resolves to inside a DST jump. See #919 for more. ## How Has This Been Tested? Added two new test cases, and [made sure they triggered the infinite loop](https://github.com/kelektiv/node-cron/actions/runs/12539141178/attempts/1?pr=938) before writing the fix. ## Screenshots (if appropriate): ## Types of changes <!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [X] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) ## Checklist: - [X] My code follows the code style of this project. - [ ] My change requires a change to the documentation. - [ ] I have updated the documentation accordingly. - [X] I have added tests to cover my changes. - [X] All new and existing tests passed. - [ ] If my change introduces a breaking change, I have added a `!` after the type/scope in the title (see the Conventional Commits standard).
🎉 This issue has been resolved in version 3.3.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
## [3.3.2](kelektiv/node-cron@v3.3.1...v3.3.2) (2024-12-30) ### 🐛 Bug Fixes * fix infinite loop on expressions resolving only inside a DST forward jump ([kelektiv#938](kelektiv#938)) ([efb8df5](kelektiv@efb8df5)), closes [/github.com/kelektiv/pull/667/files#diff-c14c2dca8456f15417b39cfbd9758009f8eb4f3a190a415768d6e4ae6ae9dceeL473-L477](https://github.com/kelektiv//github.com/kelektiv/node-cron/pull/667/files/issues/diff-c14c2dca8456f15417b39cfbd9758009f8eb4f3a190a415768d6e4ae6ae9dceeL473-L477) [kelektiv#919](kelektiv#919) [kelektiv#919](kelektiv#919) ### ⚙️ Continuous Integrations * **action:** update marocchino/sticky-pull-request-comment action to v2.9.0 ([kelektiv#930](kelektiv#930)) ([1e7bce9](kelektiv@1e7bce9)) * **renovate:** pin GitHub action digests to semver ([kelektiv#926](kelektiv#926)) ([6541167](kelektiv@6541167)) ### ♻️ Chores * **deps:** lock file maintenance ([70c3339](kelektiv@70c3339)) * **deps:** lock file maintenance ([afad454](kelektiv@afad454)) * **deps:** lock file maintenance ([b1dbf69](kelektiv@b1dbf69)) * **deps:** pin dependencies ([kelektiv#915](kelektiv#915)) ([dfcbd3c](kelektiv@dfcbd3c)) * **deps:** update dependency [@commitlint](https://github.com/commitlint)/cli to v19.6.1 ([7999427](kelektiv@7999427)) * **deps:** update dependency [@semantic-release](https://github.com/semantic-release)/release-notes-generator to v14.0.2 ([93c9373](kelektiv@93c9373)) * **deps:** update dependency [@types](https://github.com/types)/node to v20.17.10 ([9313ffd](kelektiv@9313ffd)) * **deps:** update dependency lint-staged to v15.2.11 ([100c9ff](kelektiv@100c9ff))
Description
The following snippet blocks the process
Expression at crontab.guru
What causes the issue is the fact that in Portugal the daylight savings starts at Mar 30 so the 01:00 does not actually exist.
Expected Behavior
Next execution date to be returned or an error/ warning to be shown
Actual Behavior
The process hangs forever
Possible Fix
Steps to Reproduce
Context
Your Environment
cron
version: 3.2.1The text was updated successfully, but these errors were encountered: