ADR-003: Jobs & Scheduling — Vercel Cron + Supabase Jobs Table

Status

Accepted

Context

Our ingestion workers need a reliable nudge every few minutes. Supabase’s pg_cron isn’t guaranteed in every project yet, and we wanted scheduling that fits naturally with the Vercel deploy pipeline.

Options considered

  • Vercel Cron → Next API → Edge Functions — Hosted schedule, secret headers, and easy observability in Vercel.
  • GitHub Actions — Works, but slower feedback and harder to secure with secrets.
  • pg_cron + pg_net — Attractive once it’s generally available, but not portable today.

Decision

Use Vercel Cron to ping /api/cron/rss and /api/cron/x. The handlers (see web/src/app/api/cron/rss/route.ts) validate the shared secret, then call the appropriate Supabase Edge Function with the service-role key. Every run writes a log row into public.jobs so we can trace failures.

Consequences

Upside

  • Configuration lives alongside other Vercel project settings.
  • We can replay a job by curling the cron endpoint locally.
  • The jobs table doubles as an observability feed; see supabase/functions/rss-fetch/index.ts.

Trade-offs

  • We now depend on Vercel uptime for ingestion triggers.
  • When we eventually migrate to pg_cron we’ll need to update the ADR and remove the HTTP middleman.
  • Cron handlers: web/src/app/api/cron/*
  • Job logging: supabase/functions/rss-fetch/index.ts
  • Related ADRs: ADR-001, ADR-005