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

"0 1 30 3 *" creates infinite loop #919

Open
AndreMaz opened this issue Nov 15, 2024 · 2 comments
Open

"0 1 30 3 *" creates infinite loop #919

AndreMaz opened this issue Nov 15, 2024 · 2 comments
Labels
type:bug Bug reports and bug fixes

Comments

@AndreMaz
Copy link

Description

The following snippet blocks the process

import { CronJob } from "cron";
const job2 = new CronJob(
  "0 1 30 3 *",
  function () {
    console.log("You will see this message every second");
  }, // onTick
  null, // onComplete
  false, // start
  "Europe/Lisbon" // timeZone
);

console.log(job2.nextDates(1));

Expression at crontab.guru
image

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.1
  • NodeJS version: v20.14.0
  • Operating System and version: Ubuntu LTS 24.04
@AndreMaz
Copy link
Author

Attached the debugger and tried to see what's going on.

Turns out that it gets "stuck" in while(true) {} statement in getNextDateFrom() method
image

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?

@AndreMaz AndreMaz changed the title "0 1 30 3 *" causes process to hang "0 1 30 3 *" creates infinite loop Nov 21, 2024
@intcreator
Copy link
Collaborator

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

@intcreator intcreator added the type:bug Bug reports and bug fixes label Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Bug reports and bug fixes
Projects
None yet
Development

No branches or pull requests

2 participants