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

Specifying timezone causes no trigger using croner <= 7.x #225

Closed
jefbarn opened this issue Dec 3, 2023 · 9 comments
Closed

Specifying timezone causes no trigger using croner <= 7.x #225

jefbarn opened this issue Dec 3, 2023 · 9 comments

Comments

@jefbarn
Copy link

jefbarn commented Dec 3, 2023

This doesn't do anything:

  Cron('* * * * * *', { timezone: 'America/Anchorage' }, () => {
    console.log('test')
  })

This works:

  Cron('* * * * * *', () => {
    console.log('test')
  })
@jefbarn jefbarn added the bug label Dec 3, 2023
@jefbarn jefbarn changed the title Specifying timezone causes no Specifying timezone causes no trigger Dec 3, 2023
@Hexagon
Copy link
Owner

Hexagon commented Dec 3, 2023

Interersting, can confirm this happens with multiple timezones resolving to AKDT.

@Hexagon
Copy link
Owner

Hexagon commented Dec 3, 2023

@jefbarn Please check if upgrading to croner@7.0.6-dev.0 resolves this issue.

@jefbarn
Copy link
Author

jefbarn commented Dec 3, 2023

Verified croner@7.0.6-dev.0 is working with timezone: 'America/Anchorage'
Thanks!

@Hexagon
Copy link
Owner

Hexagon commented Dec 11, 2023

Released in stable channel through 8.0.0

@victorird
Copy link

Thanks for the fix @Hexagon . However I tried the 7.0.6-dev.0 branch with Node.js 16 and it throws the following error:

RangeError: Value shortOffset out of range for Date.prototype.toLocaleString options property timeZoneName
    at Date.toLocaleString (<anonymous>)
    at getTimezoneOffset (/home/vagrant/projects/itheia-app/api/node_modules/croner/dist/croner.min.cjs:1:1284)
    at Function.minitz.fromTZ (/home/vagrant/projects/itheia-app/api/node_modules/croner/dist/croner.min.cjs:1:359)
    at minitz (/home/vagrant/projects/itheia-app/api/node_modules/croner/dist/croner.min.cjs:1:75)
    at CronDate.getDate (/home/vagrant/projects/itheia-app/api/node_modules/croner/dist/croner.min.cjs:1:17226)
    at CronDate.getTime (/home/vagrant/projects/itheia-app/api/node_modules/croner/dist/croner.min.cjs:1:17361)
    at Cron.msToNext (/home/vagrant/projects/itheia-app/api/node_modules/croner/dist/croner.min.cjs:1:20340)
    at Cron.schedule (/home/vagrant/projects/itheia-app/api/node_modules/croner/dist/croner.min.cjs:1:20975)
    at new Cron (/home/vagrant/projects/itheia-app/api/node_modules/croner/dist/croner.min.cjs:1:19159)
    at Cron (/home/vagrant/projects/itheia-app/api/node_modules/croner/dist/croner.min.cjs:1:17825)

I'm guessing the syntax in 7.0.6-dev.0 is only supported for Node.js >= 18. We're unable to move to Node.js 18 at the moment due to hardware vendor limitation. Is there any chance you can make this bugfix work with Node.js 16? Thx again.

@Hexagon
Copy link
Owner

Hexagon commented Feb 5, 2024

@victorird Oh, thanks for reporting this! Released a potential hot fix in croner@7.0.6-dev.1 (channel croner@legacy-node-support), where i added the following code as a quick workaround for AKDT and AKST not being supported by Date.parse():

	// Convert non-supported timezones
	// - Hotfix for AKST and AKDT 7.0-branch of Croner, fixed for real in 8.0
	tz = tz.replace("AKST","-0900").replace("AKDT","-0800");

Hacky, but i hope it should do for those who cannot go to 8.x. Please let me know if this works for you, and i'll release 7.0.6 stable.

@victorird
Copy link

@victorird Oh, thanks for reporting this! Released a potential hot fix in croner@7.0.6-dev.1 (channel croner@legacy-node-support), where i added the following code as a quick workaround for AKDT and AKST not being supported by Date.parse():

	// Convert non-supported timezones
	// - Hotfix for AKST and AKDT 7.0-branch of Croner, fixed for real in 8.0
	tz = tz.replace("AKST","-0900").replace("AKDT","-0800");

Hacky, but i hope it should do for those who cannot go to 8.x. Please let me know if this works for you, and i'll release 7.0.6 stable.

Thanks for the quick hot fix. I tested it and it's working flawlessly!

@Hexagon Hexagon reopened this Feb 5, 2024
@Hexagon
Copy link
Owner

Hexagon commented Feb 5, 2024

Nice! Added support for AST and released croner@7.0.6-dev.2, will let this version linger for a while before releasing the stable version.

@Hexagon Hexagon changed the title Specifying timezone causes no trigger Specifying timezone causes no trigger (in version <= 7.x) Feb 5, 2024
@Hexagon Hexagon changed the title Specifying timezone causes no trigger (in version <= 7.x) Specifying timezone causes no trigger using croner <= 7.x Feb 5, 2024
@Hexagon
Copy link
Owner

Hexagon commented Feb 18, 2024

Resolved in the 7.x branch through 7.0.7

@Hexagon Hexagon closed this as completed Feb 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants