fix(admin): report a stopped scheduler when no tick has run, with a health route for uptime checks

Aperta
#762 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
next.js, playwright, supabase, typescript

Direzione di ricerca

Start with src/lib/jobs/runner.ts and src/lib/jobs/store.ts to trace how runTick records work, then inspect the migration and src/app/super-admin/page.tsx health check. Add the health route under src/app/api/ and update docs/operations/deploy.md step 8 and docs/operations/jobs.md. Done when the listed tests cover tick privileges, an empty queue, both overview states, and the route’s 200/503 responses.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

area: admin area: jobs bug impact: high priority: P1 size: S

Context

Found by the Fable pre-production review on 2026-12-02 (main at cedc1914; every line reference below re-checked on main at cde5aa3b). Sources: platform triage report new issue 4, and deploy readiness report new issue 3.

The instance overview says the scheduler is running when no tick has ever run:

  • schedulerCheck answers "Running" unless a queued job has waited more than 10 minutes (src/app/super-admin/page.tsx:465-490), fed by admin_job_health, which reads queued rows only (supabase/migrations/20261112101200_super_admin_overview.sql:149-157).
  • Only the tick queues scheduled work (scheduleDueJobs, src/lib/jobs/schedule.ts:34-43), so with no tick nothing is ever waiting, and the check stays "Running".
  • No tick is recorded anywhere except a log line (src/app/api/jobs/tick/route.ts:28).
  • docs/operations/deploy.md:348 uses "the scheduler is running" on /app/admin as a deploy check, and no route exists for an uptime monitor (src/app/api/ has connections, dev, jobs/tick, mcp, notifications, public, support, v1, webhooks).

Impact: the operator. A cron job that was never registered, a rotated CRON_SECRET, or a tick that redirects (#756) shows "Running" and "Nothing needs attention" while nothing syncs. Users see stale data with no explanation. The uptime half of #91 needs a route to call.

Plan

  1. Record each tick's start and finish (a small table or a row per tick kept for a bounded time), written by runTick.
  2. schedulerCheck reports attention when the last tick started more than 5 minutes ago or none has ever run, with or without connections and queued jobs.
  3. Add a health route under src/app/api/ that reports only whether the database answers and whether the last tick is recent: no counts, no ids, Cache-Control: no-store. An uptime monitor (#91) calls it.
  4. Name the new signal in deploy.md step 8.

Acceptance criteria

  • Each tick records when it started and finished.
  • /app/admin shows attention when no tick ran in the last 5 minutes, including with an empty queue and no connections.
  • The health route answers 200 when the database answers and the last tick is recent, and 503 otherwise, with no data beyond that.
  • Unit test for the empty queue case; pgTAP for the tick record's privileges.
  • Playwright e2e covers both overview states.
  • deploy.md step 8 names the signal and the health route.

Files and areas

src/lib/jobs/runner.ts, src/lib/jobs/store.ts, a migration, src/app/super-admin/page.tsx, a new route under src/app/api/, docs/operations/deploy.md, docs/operations/jobs.md.

Non-goals: choosing the uptime vendor (#91), alerting by email on failed jobs.

Verification

npm run typecheck, npm run lint, npx vitest run src/lib/jobs, npm run test:db, the super admin e2e spec.


Branch: <issue-number>-scheduler-heartbeat

Model: anthropic/claude-opus-5-5 | Reasoning effort: unknown

Lingua principale
TypeScript
Stelle
13
Fork
2
Merge medio
5h 20m
PR unite (30g)
287

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di eddiejaoude/StackDash

Tutte le issue di eddiejaoude/StackDash

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.