Monitor Cloudflare Workers Cron Triggers
A Cloudflare Worker's scheduled handler runs on a cron expression defined in wrangler.toml. Pinging at the end of the handler confirms it actually completed, not just that Cloudflare invoked it.
Setup
Create an incoming monitor
Add a heartbeat monitor in Pingtastic matching the cron schedule.
Ping at the end of the scheduled() handler
Add the ping call after the real work succeeds.
export default {
async scheduled(event, env, ctx) {
// ...existing job logic...
await fetch('https://ping.pingtastic.net/ping/nightly-sync');
},
};Define the schedule in wrangler.toml
Keep it in sync with the monitor's grace period.
[triggers]
crons = ["0 6 * * *"]Gotchas
- ⚠Workers have a CPU time limit per invocation — a scheduled handler that times out partway through never reaches the ping call, which is correct, but check Cloudflare's dashboard logs if pings go missing to rule out a silent timeout versus a logic error.
- ⚠A wrangler.toml change to the cron schedule only takes effect after a deploy — editing the file without redeploying leaves the old schedule active on Cloudflare's side.
Questions
Does Cloudflare alert me if a Cron Trigger fails?
Cloudflare's dashboard shows recent invocation logs, but there's no built-in proactive alerting for a failed or silently-skipped scheduled invocation — that's the gap a heartbeat ping closes.
Can I use ctx.waitUntil() for the ping call?
Yes — wrapping the ping fetch in ctx.waitUntil() is a good idea if you want the scheduled handler to return before the ping request fully completes, without risking Cloudflare terminating the Worker early.
Related guides
Start monitoring your Cloudflare Workers cron triggers
Set up your first monitor in under five minutes.
Get started — $5/month