Originally published on meridianbuild.dev, my build log for FastPass, a paid inbox where people pay to reach you and get refunded if you don't reply.
FastPass makes one promise to the person who pays: if the recipient does not reply before the deadline, you get your money back. The sender picks the window when paying, 24, 48 or 72 hours. Halfway through, and again at 75%, the recipient gets a reminder email.
None of that happens on its own. Something has to wake up, look for messages whose deadline has passed, and trigger the refunds. For FastPass, that something was a GitHub Actions workflow with this at the top:
on: schedule: - cron: '*/10 * * * *' Every 10 minutes. The comment next to it even said "more precise". It had been there since July 2025.
This week I pulled its run history and counted.
What "every 10 minutes" looked like
A schedule of */10 * * * * is 144 runs a day, about 4,320 in a 30 day month. Here is what the run history of that workflow shows for scheduled runs:
| Month | Scheduled runs | Per day | Median gap between runs | Longest gap |
|---|---|---|---|---|
| September 2026 | 196 | 6.5 | 3.5 h | 7.9 h |
| October 2026 | 165 | 5.3 | 4.5 h | 9.5 h |
| November 2026 | 105 | 3.5 | 6.8 h | 13.2 h |
And it kept sliding. Between December 1 and December 2, there were 21 hours without a single run.
So the job that refunds people ran, on a typical November day, three or four times. The median wait between two runs was almost seven hours.
Look at it from the recipient's side. On a 24 hour window, the second reminder is due at hour 18, six hours before the deadline. With a 13 hour gap between two runs, that reminder can simply never go out in time. And on the sender's side, "refunded if no reply" quietly became "refunded at some point after the deadline, when the scheduler gets to it".
I don't have a clean per refund measurement of how late each one went out, so I won't put a number on it. The schedule data is enough to say the promise was not being kept on time.
Why nothing told me
This is the part I want to remember.
The workflow had a failure alert. If the step that checks expired escrows still failed after three attempts, it posted to a Discord webhook: "Critical: The escrow timeout check job failed. This could delay refunds to senders!" I was proud of that alert.
Of the 998 scheduled runs in the history I pulled, 995 succeeded.
A run that never starts cannot fail. The alert was watching the quality of the runs, and the problem was the number of runs. Every run GitHub did make came back green, so the Actions tab looked healthy every time I opened it. The only way to see the problem was to count runs against the clock, which I had never done.
GitHub does warn about this in its docs: scheduled workflows can be delayed when Actions is under heavy load. I had read that, and filed it under "a few minutes late sometimes". It was hours.
Moving the clock into the database
FastPass runs on Supabase, and the database already knows about every deadline. Postgres on Supabase ships two extensions that make it a decent scheduler: pg_cron to run SQL on a schedule, and pg_net to make an HTTP call from SQL. The two jobs are Edge Functions already (send-deadline-reminders and check-escrow-timeouts), so all the database has to do is call them.
The migration (commit 869cec7) adds one function that calls a scheduled Edge Function:
CREATE OR REPLACE FUNCTION public.invoke_scheduled_function(p_function text) RETURNS bigint LANGUAGE plpgsql SECURITY DEFINER SET search_path TO '' AS $function$ DECLARE v_url text; v_key text; v_request_id bigint; BEGIN IF p_function IS NULL OR p_function !~ '^[a-z0-9-]+$' THEN RAISE EXCEPTION 'invalid function name'; END IF; SELECT decrypted_secret INTO v_url FROM vault.decrypted_secrets WHERE name = 'scheduler_project_url'; SELECT decrypted_secret INTO v_key FROM vault.decrypted_secrets WHERE name = 'scheduler_function_key'; IF v_url IS NULL OR v_key IS NULL THEN RAISE WARNING 'invoke_scheduled_function(%): scheduler secrets are not configured', p_function; RETURN NULL; END IF; SELECT net.http_post( url := rtrim(v_url, '/') || '/functions/v1/' || p_function, headers := jsonb_build_object('Content-Type', 'application/json', 'Authorization', 'Bearer ' || v_key), body := '{}'::jsonb, timeout_milliseconds := 120000 ) INTO v_request_id; RETURN v_request_id; END; $function$; REVOKE ALL ON FUNCTION public.invoke_scheduled_function(text) FROM PUBLIC, anon, authenticated, service_role; Then two schedules:
SELECT cron.schedule('send-deadline-reminders', '*/10 * * * *', $$SELECT public.invoke_scheduled_function('send-deadline-reminders')$$); SELECT cron.schedule('check-escrow-timeouts', '2-59/10 * * * *', $$SELECT public.invoke_scheduled_function('check-escrow-timeouts')$$); A few decisions in there that took longer than the code.
The key is not in the migration. The URL and the key the jobs send live in Supabase Vault, set by hand, out of band. Migrations are in git, and a key in git is a key you will be rotating one day. If the Vault entries are missing, the function logs a warning and does nothing, so a fresh database or a test database never fires real HTTP calls.
The function name is checked. p_function is pasted into a URL, so it must match ^[a-z0-9-]+$. A value like ../auth/v1/admin is refused before any request is built.
Nobody on the API can call it. The function is SECURITY DEFINER because it reads Vault, which makes it powerful. REVOKE ALL ... FROM PUBLIC, anon, authenticated, service_role means only the database owner, which is what pg_cron runs as, can call it. Without that line, any logged in user could have triggered the refund job through the REST API whenever they liked.
The two jobs are offset by two minutes. Reminders run at :00, :10, :20. The timeout check runs at :02, :12, :22. They don't compete for the same minute, and the logs are easier to read.
Keeping the old clock
I did not delete the GitHub workflow. It still runs, whenever GitHub gets to it, as a fallback in case the database scheduler stops.
That only works because running a job twice is safe. The reminder function records reminder_1_sent_at and reminder_2_sent_at on the transaction and skips what was already sent. The refund call to Stripe carries an idempotency key built from the transaction:
'Idempotency-Key': `refund-${transaction.id}`, So if the database job and the workflow both pick up the same expired escrow, Stripe sees the same refund request twice and makes one refund. If your scheduled job is not safe to run twice, you can't have two schedulers, and you are back to trusting one clock.
Tests for a scheduler
The migration came with additions to the database test bench I already run against a copy of the schema:
-
anon,authenticatedandservice_roleeach try to callinvoke_scheduled_functionand must be denied. - An authenticated user tries to read
vault.decrypted_secretsand must be denied. - Both jobs must exist in
cron.job, active, on a 10 minute schedule. - Without the Vault secrets, a call returns nothing and queues no HTTP request.
- With test secrets, a call queues exactly one request to the right URL, with the key in the header.
- A function name that tries to leave
/functions/v1/is refused.
The bench runs on plain Postgres, so it fakes the small parts of cron, net and vault that the migration uses. That is enough to test the rules. It does not prove that Supabase's real scheduler fires on time, which is why I checked production after the deploy.
What production says so far
The first database run happened on December 2 at 13:50 UTC. By 20:42 UTC the same day, each job had run 42 times, every 10 minutes, without a gap. Every HTTP response the database still had on record was a 200.
That is a few hours of data, not a month. But it already beats what the old schedule did in most of November in a whole day.
What I'd tell anyone with a deadline on a cron
- If money or a promise depends on a scheduled job, count its runs against the clock. A green dashboard only tells you about the runs that happened.
- Alert on silence, not only on failure. "No successful run in the last 30 minutes" would have caught this months ago.
- A free CI scheduler is fine for a nightly report. It is not a timer.
- Put the schedule as close to the data as you can. For FastPass that meant the database.
- Make the job safe to run twice. Then a second scheduler is a free safety net instead of a risk.
I wrote earlier about webhooks that failed 96% of the time on the same product. Same lesson in a different shape: the parts of a payment flow that run in the background are the ones you look at last, and they are the ones holding the promise.
