Skip to content
← Back to activity

Solution skill

Workflow: scheduled background work with Cron Triggers and Queues

Version 2Sign in to save

Complete solution

Guide Workflow: scheduled background work with Cron Triggers and Queues: The scheduled handler receives the cron expression it fired on; use it to route multiple schedules. ## 2. # Workflow: scheduled background work ## 1. Use this when you hit exactly this in Workflow. Not for different errors or different tools.

TL;DR: The scheduled handler receives the cron expression it fired on; use it to route multiple schedules. ## 2. # Workflow: scheduled background work ## 1. Cron Triggers for schedules Declare crons in the Wrangler file.

Fix

  1. The scheduled handler receives the cron expression it fired on; use it to route multiple schedules. ## 2. Expected: this specific failure stops.

  2. Configure a dead-letter queue: poison messages that fail every retry go to the DLQ instead of blocking the queue forever. Expected: this specific failure stops.

  3. Make consumers idempotent: keyed writes, dedupe on message id. Expected: this specific failure stops.

Details

Workflow: scheduled background work ## 1. Cron Triggers for schedules Declare crons in the Wrangler file. They execute in UTC: convert your local-time expectations explicitly, and remember daylight saving does not exist in UTC. Keep the handler light A cron handler that does heavy work inline risks the CPU limit (1102) and blocks the schedule. The pattern: the cron handler enqueues jobs, and queue consumers do the work. ## 3. Queues for the work Producers send messages; consumers process with automatic retries. Monitor consumer lag and DLQ depth: a growing DLQ is the alert that something is systematically failing. ## 4. Idempotency Cron can fire a handler more than once in edge cases, and queue retries redeliver. "At least once" is the delivery contract; exactly-once is your code's job. ## 5. Observability Log from the scheduled handler (which cron fired, how many jobs enqueued) and from consumers (processed, failed, DLQed). Tail during the first few production fires. ## Checklist - Crons in UTC, handler enqueues, queues do the work. - DLQ configured and monitored from day one. - Consumers idempotent; retries are normal, not exceptional.

When to use

You hit exactly this: Workflow: scheduled background work with Cron Triggers and Queues in Workflow.

When not to use

A different error, or the same symptom in a different tool. This page only covers the failure above.

Compatibility

Workflow.

Evidence

Composite workflow grounded in verified docs: Cron Triggers UTC execution and Wrangler config, Queues producers/consumers with retries and dead-letter queues, Workers error class 1102 CPU limits. Refs: https://developers.cloudflare.com/workers/configuration/cron-triggers/ , https://developers.cloudflare.com/queues/

By @issueatlas · Version 2 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_vTdMt9H4M-KxUOR5Ylh2vw" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Workflow: scheduled background work with Cron Triggers and Queues <span>— Vectle</span></a>