From be8072ce88f6900a3ec5a8efa30ede76b18587f2 Mon Sep 17 00:00:00 2001 From: caelum0x Date: Mon, 26 Oct 2026 16:55:38 +0300 Subject: [PATCH] fix(insights-edge): weekly report cron fired every Sunday, not Monday MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cloudflare Cron Triggers number weekdays 1=Sunday..7=Saturday (Quartz-style), not the POSIX 0=Sunday..6=Saturday most cron syntax assumes. The configured trigger "0 7 * * 1" was written assuming POSIX semantics (1=Monday) but Cloudflare resolved it as Sunday — confirmed against three real delivered digest emails (2026-10-11/18/25, all Sunday 07:00-07:01 UTC). Switched to the unambiguous "0 7 * * MON" literal per Cloudflare's own docs recommendation. Verified live: redeployed, confirmed the new schedule via the Workers API, and triggered a real POST /api/report to confirm the send path still works end to end (real email landed in the inbox within seconds). --- apps/insights-edge/src/report.mjs | 4 +++- apps/insights-edge/wrangler.jsonc | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/apps/insights-edge/src/report.mjs b/apps/insights-edge/src/report.mjs index 0246b740..4965c679 100644 --- a/apps/insights-edge/src/report.mjs +++ b/apps/insights-edge/src/report.mjs @@ -1,6 +1,8 @@ // Weekly funnel report: every site in the SITES KV, last 7 full UTC days // against the 7 before, emailed through Scribase Mail (Rally Send protocol). -// Runs from the Worker cron (Mondays 07:00 UTC) and from POST /api/report. +// Runs from the Worker cron (Mondays 07:00 UTC -- wrangler.jsonc's "triggers.crons", +// fixed 2026-10-26 to "0 7 * * MON" after it silently fired every Sunday for weeks; +// see the comment there) and from POST /api/report. import { siteStats } from "./store.mjs"; diff --git a/apps/insights-edge/wrangler.jsonc b/apps/insights-edge/wrangler.jsonc index 375e8a42..bbc18580 100644 --- a/apps/insights-edge/wrangler.jsonc +++ b/apps/insights-edge/wrangler.jsonc @@ -21,7 +21,13 @@ // `//.json`. Create once with `wrangler r2 bucket create railyard-insights-replay`. "r2_buckets": [{ "binding": "REPLAY", "bucket_name": "railyard-insights-replay" }], // Weekly funnel report, Mondays 07:00 UTC, through Scribase Mail. - "triggers": { "crons": ["0 7 * * 1"] }, + // NB (found 2026-10-26): Cloudflare Cron Triggers number weekdays 1=Sunday..7=Saturday + // (Quartz-style), NOT the POSIX 0=Sunday..6=Saturday most cron docs assume. "0 7 * * 1" + // therefore actually fired every SUNDAY 07:00 UTC in production for weeks (confirmed via + // the real delivered digest emails: 2026-10-11, -18, -25 all landed Sunday 07:00-07:01 + // UTC, not Monday). Using the three-letter abbreviation instead, as Cloudflare's own docs + // recommend, to avoid this ambiguity ever recurring. + "triggers": { "crons": ["0 7 * * MON"] }, // Namespace RAILYARD_SITES, created 2026-09-30 (`wrangler kv namespace create RAILYARD_SITES`). "kv_namespaces": [{ "binding": "SITES", "id": "323121abfdc64ff6ab90927620d3dbb2" }], "vars": {