👋 I've got a simple list of schedules

👋 I've got a simple list of schedules like this in worker:
"triggers": {
"crons": ["* * * * *", "*/2 * * * *"]
},
"triggers": {
"crons": ["* * * * *", "*/2 * * * *"]
},
But when I deploy this, the value of controller.cron inside my worker's scheduled callback is always * * * * * - this makes it impossible to differentiate between the two different schedules. Is this a known issue? If so, is there any workaround?
4 Replies
jonast
jonastOP•2w ago
I believe this means the example from the docs here doesn't work either? https://developers.cloudflare.com/workers/examples/multiple-cron-triggers/
switch (controller.cron) {
case "*/3 * * * *":
// Every three minutes
await updateAPI();
break;
case "*/10 * * * *":
// Every ten minutes
await updateAPI2();
break;
case "*/45 * * * *":
// Every forty-five minutes
await updateAPI3();
break;
}
switch (controller.cron) {
case "*/3 * * * *":
// Every three minutes
await updateAPI();
break;
case "*/10 * * * *":
// Every ten minutes
await updateAPI2();
break;
case "*/45 * * * *":
// Every forty-five minutes
await updateAPI3();
break;
}
Because 45 is divisible by 3, controller.cron would never match the third case
Cloudflare Docs
Multiple Cron Triggers
Set multiple Cron Triggers on three different schedules.
jonast
jonastOP•2w ago
Oh wait, this behaviour ONLY seems to happen when using * * * * *
jonast
jonastOP•2w ago
No description
jonast
jonastOP•2w ago
Note the /2 and /4 firing separately at the same time Okay, so a less severe bug 😌 A bug nonetheless. Where best to file this? Good shout - am trying it now Works So only * * * * * is poison

Did you find this page helpful?