Monitor Cloudflare Workers Cron Triggers

On this page

A Cloudflare Worker with a Cron Trigger can stop running for reasons you do not see in your code: a configuration change that is still propagating, a CPU limit, or a trigger removed in a deploy. Ping from the scheduled handler and you hear about the run that never came.

How can a scheduled job fail silently on Cloudflare Cron Triggers?

  • Cron Triggers execute on UTC time, whatever time zone you work in.
  • Changes to Cron Triggers, whether adding, editing or deleting one, can take several minutes, up to 15 minutes, to reach the Cloudflare network.
  • Cloudflare says scheduled Workers run on underutilized machines, so timing depends on capacity.
  • The CPU time limit for a Cron Trigger is 10 ms on the Free plan; on the Paid plan it is 30 seconds for triggers that run more often than hourly, and 15 minutes for hourly or less frequent ones.
  • A scheduled invocation has a wall time of at most 15 minutes.

What are the limits of Cloudflare Cron Triggers?

LimitWhat the documentation says
Cron Triggers per account5 on the Free plan, 250 on the Paid plan.
CPU timeFree: 10 ms. Paid: 30 seconds under a 1 hour interval, 15 minutes at 1 hour or more.
Wall time15 minutes per scheduled invocation.
Time zoneUTC.
PropagationChanges can take up to 15 minutes to reach the network.

How do you add a CronMissed ping to Cloudflare Cron Triggers?

Use ctx.waitUntil so the ping is sent without delaying the handler, and ping /start first when the handler is long. Store the ping URL as a secret binding.

src/index.js
export default {
  async scheduled(controller, env, ctx) {
    const ping = (suffix = '', body) =>
      fetch(env.PING_URL + suffix, { method: body ? 'POST' : 'GET', body, signal: AbortSignal.timeout(10000) }).catch(() => undefined);
    ctx.waitUntil(ping('/start'));
    try {
      await runJob(env);
      ctx.waitUntil(ping());
    } catch (error) {
      ctx.waitUntil(ping('/fail', String(error?.stack ?? error).slice(-100000)));
      throw error;
    }
  },
};

async function runJob(env) {
  // the work
}
wrangler.jsonc
{
  "triggers": { "crons": ["15 3 * * *"] }
}

Which check settings fit Cloudflare Cron Triggers?

Create a cron check with the trigger's expression in UTC. Add 15 minutes of grace after any change to the triggers, since the new schedule may not be live yet. Otherwise a few minutes of grace is enough. If the handler can exceed the CPU limit on the Free plan, the start ping lets you tell a Worker that never started from one that was cut off.

How do you confirm the check works?

  1. Use wrangler dev with the scheduled test endpoint, or trigger the handler from the dashboard, and confirm the pings.
  2. Throw an error in runJob and confirm /fail reaches the check.
  3. Remove the trigger, deploy, and confirm the check goes late and then down.

Sources

Questions and answers

Why use waitUntil for the ping?
It lets the Worker finish its response work while the request to CronMissed completes in the background, within the invocation's limits.
Does a Cron Trigger retry on failure?
The handler can call controller.noRetry() to opt out of retries, which shows that retries are part of the platform. A heartbeat still sees the final outcome: a run that never succeeds never sends the ping.
Know when this job stops

Create a check, add the ping to the job, and CronMissed alerts you the first time a run is late or reports a failure.

Start monitoring