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

tried so hard #50

Open
joe-at-startupmedia opened this issue Nov 2, 2024 · 5 comments
Open

tried so hard #50

joe-at-startupmedia opened this issue Nov 2, 2024 · 5 comments

Comments

@joe-at-startupmedia
Copy link

joe-at-startupmedia commented Nov 2, 2024

I started getting this error last night. My suspicion is that it may be related to standard time switchover? Nothing has been changed with the code nor the configuration for months.

Code:

func (j *JobSpec) setNextTick(refTime time.Time, includeRefTime bool) error {
  if j.Cron != "" {
    t, err := gronx.NextTickAfter(j.Cron, refTime, includeRefTime)
    j.nextTick = t
    fmt.Printf("\njCron: %s, refTime: %v, includeRefTime: %v, %-v\n", j.Cron, refTime, includeRefTime, err)
    return err
  }
  return nil
}

Couple instance of failures:

jCron: 10 12 * * *, refTime: 2024-11-02 19:39:33.031482225 -0400 EDT, includeRefTime: true, tried so hard
jCron: 15 05 * * *, refTime: 2024-11-02 19:40:14.304755524 -0400 EDT, includeRefTime: true, tried so hard
jCron: 20 05 * * *, refTime: 2024-11-02 19:40:36.725177004 -0400 EDT, includeRefTime: true, tried so hard

The same code works for other instances:

jCron: 15 00  * * *, refTime: 2024-11-02 19:40:36.723989643 -0400 EDT, includeRefTime: true, <nil>

jCron: 25 00 * * *, refTime: 2024-11-02 19:40:36.724409077 -0400 EDT, includeRefTime: true, <nil>

jCron: 35 00 * * *, refTime: 2024-11-02 19:40:36.724593286 -0400 EDT, includeRefTime: true, <nil>

jCron: 0 0 1 * *, refTime: 2024-11-02 19:40:36.724980983 -0400 EDT, includeRefTime: true, <nil>
@joe-at-startupmedia
Copy link
Author

version is: github.com/adhocore/gronx v1.8.1

@joe-at-startupmedia
Copy link
Author

joe-at-startupmedia commented Nov 3, 2024

Update:

The following modification fixes the issue:

func (j *JobSpec) setNextTick(refTime time.Time, includeRefTime bool) error {
  if j.Cron != "" {
    refTime, _ = time.Parse(time.RFC3339, refTime.Format(time.RFC3339))
    t, err := gronx.NextTickAfter(j.Cron, refTime, includeRefTime)
    j.nextTick = t
    return err
  }
  return nil
}

2024-11-02 19:40:36.723989643 -0400 EDT,
I'm not sure where this time format is coming from but it seems to be the source of the issue. The code replicating this issue is coming from cheek where s.loc is declared from America/New_York

joe-at-startupmedia added a commit to joe-at-startupmedia/cheek-turner that referenced this issue Nov 3, 2024
@adhocore
Copy link
Owner

adhocore commented Nov 7, 2024

hello Joe, thanks for reporting issue. first, could you check if latest version is working?

@joe-at-startupmedia
Copy link
Author

At the time of the issue, I had cecked if upgrading to the latest verion of gronx fixed the issue: it did not. In my ability to replicate on an isolated environment, I could not replicate because the now function was not producing the following format:

2024-11-02 19:40:36.725177004 -0400 EDT

While checking the docs for the std time package, I could not find a name for that format, nor was I able to successfully parse a string from that format into a new time instance without errors. At this point, the issue may not be replicable on a revert from my fix above due to the rollover to standard time, but I will try it later and provide an update.

@joe-at-startupmedia
Copy link
Author

joe-at-startupmedia commented Nov 10, 2024

checking out the commit before my fix above, no longer produces the error as I had suspected. And the code is still producing the following format:

2024-11-10 15:54:42.130695329 -0500 EST

Commit:
joe-at-startupmedia/cheek-turner@216a4be

I'd be of more service if I knew how to parse this format without errors.

go playground

In order to replicate the issue, the time has to go back to the following:

2024-11-02 19:40:36.725177004 -0400 EDT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants