MELLEPRISE MELLEPRISE AI MP Blog
← All articles

supabase cron says succeeded, but nothing happened

Pastel comic of a clock face sending a paper plane through a database queue toward an app window

Your supabase cron job appears in the dashboard. The history even says succeeded. The app still does not send the digest, expire the trial, close the invoice, or clean the table.

This is the dangerous kind of cron failure: it looks green. In many Supabase setups the job does not perform the business work directly. It queues a net.http_post call to an Edge Function. That means “the SQL job succeeded” and “the production workflow ran” are two different facts.

What supabase cron success really means

Supabase Cron uses pg_cron to run SQL on a schedule. When the SQL calls an Edge Function, it usually uses pg_net. pg_net is asynchronous: net.http_post queues a request and returns a request id. The cron row can finish successfully while the HTTP request is still waiting, has timed out, or later returns a 401, 404, 500, or a function error.

So the first rule is simple: never debug only cron.job_run_details. That table is the scheduler truth. It is not the receiver truth.

Why AI-built apps hit this so often

The AI copies the shortest example: cron expression, hard-coded function URL, publishable key, and no receiver proof. A manual function test does not prove the scheduled path, service-to-service auth, timeout, or retry safety.

AI also confuses cron time, database time and user-local time. Treat Supabase cron timing as UTC/GMT unless you have explicit conversion logic. “Every day at 9” is not a requirement until the timezone is written down.

supabase cron production click path

  1. Write down the exact expectation. Which row should change, which email should send, which entitlement should expire, and by what UTC time? Do not debug “it did not run” without a target record.
  2. Confirm the active job. In Dashboard → Integrations → Cron, check name, schedule, active state, database and command. Names are case sensitive; reusing one overwrites the job.
  3. List the jobs in SQL too. Run select jobid, jobname, schedule, command, active, username, database from cron.job order by jobname;. Look for duplicates, disabled jobs, jobs in the wrong database, and overwritten names.
  4. Inspect scheduler history. Query the last runs for the exact job:
select jobid, status, return_message, start_time, end_time
from cron.job_run_details
where jobid = (select jobid from cron.job where jobname = 'your-job-name')
order by start_time desc
limit 20;
  1. Interpret status narrowly. succeeded means the SQL command completed, not that the receiver completed the workflow.
  2. Check the pg_net response table. Match the request time and inspect the real HTTP outcome:
select id, status_code, content, error_msg, created
from net._http_response
order by created desc
limit 20;
  1. Use the request id when possible. Compare a stored net.http_post id with net._http_response.id; otherwise time, URL and payload are only evidence.
  2. Check timeout and response body. Slow functions may need explicit timeout_milliseconds; a 200 can still hide an application-level error.
  3. Open Edge Function logs. Confirm start, auth, body parsing and downstream API results. Dashboard execution and cron execution often use different headers. If the cron-specific proof is clean but the function itself still fails, continue with supabase edge functions.
  4. Verify secrets from Vault. Store project URL and secret key in Vault; do not paste long-lived secrets into cron SQL. While a request waits, pg_net can carry the decrypted value in its queue.
  5. Confirm the function auth model. A publishable key is public and must never protect a dangerous service-to-service endpoint.
  6. Check scheduler health only after the response truth. If there are no rows at all, inspect pg_stat_activity, database pressure and concurrency; Supabase documents up to 32 concurrent cron jobs.
  7. Look for overlap. If a five-minute job sometimes runs twelve minutes, two executions can send duplicate emails or process the same rows without a lock.
  8. Test idempotency deliberately. Run the receiver twice with the same input; retries must not duplicate effects.
  9. Check restored projects and branches. Restores can contain active jobs. A copy can call production endpoints before anyone edits it. Rotate receiver secrets or add an environment guard before restoring production data; treat this as part of the wider supabase backup surface.
  10. Only then edit the schedule. Changing */5 to * does not repair a 401, timeout or duplicate writer.

The failure patterns that matter most

The job succeeded because it only queued work. If net._http_response is empty, the request may never have been sent. A non-2xx means receiver trouble; a 200 with an error body means the response contract is wrong.

The function runs but rejects the cron caller. Manual Dashboard tests use your user session; cron uses the SQL headers. Missing apikey, wrong secret, wrong project ref, or unexpected user auth quietly reject the call.

The timezone was never specified. A morning job needs an explicit UTC/GMT schedule and often application-level business-time logic, not improvised local-time math in cron.

The job overlaps itself. Long SQL, network waits or slow APIs can overlap runs. If the task is not safe twice, add a database advisory lock or state machine:

select pg_try_advisory_lock(918273645) as got_lock;

Check the boolean before working and release the lock, or use a transaction-scoped lock inside a database function. The implementation belongs in a migration.

The retry duplicates effects. Cron is not exactly-once workflow infrastructure. Credits, subscriptions, emails, invoices and deletion jobs need idempotent receivers.

The history grows forever. cron.job_run_details is not cleaned automatically. Even the recommended cleanup job is destructive SQL and belongs in reviewed migrations.

Make the job observable before you trust it

A production-ready cron path has five proofs: scheduler proof in cron.job_run_details, HTTP proof in net._http_response, receiver proof in function logs, business proof in the changed target row, and duplicate-safety proof from a repeated execution.

For important jobs, write a small run ledger in the migration: job name, planned UTC time, request id, target id, status, error and completion time.

Keep cron definitions in migrations too. Dashboard-only jobs skip review and surprise the next environment; review changes with the same care as schema drift in supabase migrations.

Production checklist

  • The job has one exact business outcome and a named target record for testing.
  • Schedule, timezone meaning, active state, database and command are documented.
  • Job names are unique, case-sensitive and managed through migrations where possible.
  • cron.job_run_details and net._http_response are both checked.
  • Edge Function logs prove the receiver started and finished.
  • Project URL and secret key come from Vault; no long-lived secret is pasted into cron SQL.
  • Dangerous endpoints are not protected by a publishable key.
  • Timeouts are explicit and slow downstream work is moved out of the request path when needed.
  • Overlap is impossible or controlled with a lock/state machine.
  • Retries and manual reruns are idempotent.
  • Restore copies cannot call production endpoints with live secrets.
  • Old run history has an intentional cleanup policy.
  • The job still fits the broader lovable deploy production checklist.

Once you separate queueing from execution, the fix usually becomes visible: wrong secret, missing response row, timeout, overlapping job, duplicated effect, wrong project, or a restore copy calling production. Fix that layer. Do not “repair” a silent production workflow by making it run more often.

FAQ

Why does my Supabase cron job say succeeded but the Edge Function did nothing?

pg_net is asynchronous. cron.schedule can finish after queueing net.http_post, so the cron history may say succeeded before the HTTP request has a response. Check net._http_response for status_code, content and error_msg, then check the Edge Function logs.

Does Supabase cron use my local timezone?

Do not assume your local timezone. Supabase examples label schedules GMT and pg_cron historically defaults to GMT; operationally treat them as UTC unless you deliberately write conversion logic.

Can a restored Supabase project run my production cron jobs?

Yes. Restores and some branches can contain active jobs. If those jobs call production URLs or carry production secrets, the copy can write to the live app. Rotate receiver secrets or add an environment guard before restoring.