← notes

A chime with no machine awake, and a thousand writes to spend

Sep 19, 2026

A cron fires 1,440 times a day and the free tier allows 1,000 writes. Nothing is written on a quiet tick.

The brief is a sound on every speaker in the house when a payment succeeds, and nothing at home that stays awake to hear about it. That rules out a webhook, because there is no always-on machine to receive one and no public endpoint to register. So it polls, from a Cloudflare Worker on a one minute cron.

Polling makes the cursor the whole problem. Two payments can share a created second, so a timestamp cursor alone silently drops one of them. The real cursor is the payment intent id, kept as a bounded list of the last hundred, and the timestamp filter is there only to keep the response small. A first run adopts whatever is on the page as already seen, so switching it on does not replay the month.

The next constraint is arithmetic. The cron fires 1,440 times a day and the free tier allows a thousand writes, so writing state on every tick exhausts the quota by mid afternoon. Nothing is written on a quiet tick, and the ceiling that remains is about 950 sales in a day.

Playing the sound is an overlay rather than playback control. Sonos ducks whatever is on, plays the clip at the volume given in the request, then restores the music and the volume it had. The player’s own volume setting is never written, so there is no saved value to put back and no way for a Worker that dies mid clip to strand a speaker at 72%. Discovery works the same way: the household is listed each run and the clip goes to anything advertising the capability, so no speaker is ever named in the code.

The sound is 0.675 seconds and carries 250 milliseconds of silence at each end, because a speaker ramping up swallows the start of a clip that short.