Munchable is a barcode scanner for people with digestive conditions. Behind the app there are scheduled jobs, and two different things run them: Vercel Cron hitting a route, and a CLI a person runs in a terminal for the bulk data passes. One of those jobs announces changed pages like the recipe index to search engines every hour; another settles contributor rewards once a month.
They share one guard, withCronLock(name, fn) , which is a Redis key under cron:<name> taken with NX and a TTL. Nothing surprising. The interesting part is what that TTL used to be.
The reasonable version that was wrong
It used to be the job's whole worst-case runtime: three hours for the scheduled runner, six from the CLI. The reasoning writes itself. The lock has to outlive the run, otherwise a second runner starts while the first is still going.
That reasoning is correct.…