croner
croner copied to clipboard
Specifying timezone causes no trigger using croner <= 7.x
This doesn't do anything:
Cron('* * * * * *', { timezone: 'America/Anchorage' }, () => {
console.log('test')
})
This works:
Cron('* * * * * *', () => {
console.log('test')
})
Interersting, can confirm this happens with multiple timezones resolving to AKDT.
@jefbarn Please check if upgrading to [email protected]
resolves this issue.
Verified [email protected] is working with timezone: 'America/Anchorage' Thanks!
Released in stable channel through 8.0.0
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 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.
@victorird Oh, thanks for reporting this! Released a potential hot fix in
[email protected]
(channelcroner@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 release7.0.6
stable.
Thanks for the quick hot fix. I tested it and it's working flawlessly!
Nice! Added support for AST and released [email protected]
, will let this version linger for a while before releasing the stable version.
Resolved in the 7.x branch through 7.0.7