croner icon indicating copy to clipboard operation
croner copied to clipboard

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

Open jefbarn opened this issue 1 year ago • 8 comments

This doesn't do anything:

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

This works:

  Cron('* * * * * *', () => {
    console.log('test')
  })

jefbarn avatar Dec 03 '23 00:12 jefbarn

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

Hexagon avatar Dec 03 '23 12:12 Hexagon

@jefbarn Please check if upgrading to [email protected] resolves this issue.

Hexagon avatar Dec 03 '23 19:12 Hexagon

Verified [email protected] is working with timezone: 'America/Anchorage' Thanks!

jefbarn avatar Dec 03 '23 20:12 jefbarn

Released in stable channel through 8.0.0

Hexagon avatar Dec 11 '23 23:12 Hexagon

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.

victorird avatar Feb 05 '24 19:02 victorird

@victorird Oh, thanks for reporting this! Released a potential hot fix in [email protected] (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.

Hexagon avatar Feb 05 '24 20:02 Hexagon

@victorird Oh, thanks for reporting this! Released a potential hot fix in [email protected] (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!

victorird avatar Feb 05 '24 20:02 victorird

Nice! Added support for AST and released [email protected], will let this version linger for a while before releasing the stable version.

Hexagon avatar Feb 05 '24 21:02 Hexagon

Resolved in the 7.x branch through 7.0.7

Hexagon avatar Feb 18 '24 10:02 Hexagon