fix(plugin): stop the cache purge drain on a rate-limited batch
Summary
Prod fix found while monitoring the release of #4290. The /updates cache purge queue (updates_cache_purge_pending) stopped draining. 733 apps were due and none purged for over 30 minutes, while the API worker logged thousands of updates cache purge failed (Cloudflare 429) a minute.
The cause is in the purge drain. When Cloudflare rate-limited a batch, drainUpdatesCachePurge acked it for its Retry-After and immediately claimed the next 100 apps. Several drains run at once (each wakeup and each on_version_update nudge starts one). Together they cycled through the whole queue every few seconds, which kept the zone purge quota spent, so no purge got through. Within a batch, purgeUpdatesCacheTags also kept calling a zone after it answered 429.
- The drain stops after a failed batch. That batch is already requeued at its Retry-After, and the cron tick and the next wakeup resume once the limit clears.
- A Cloudflare zone that answered 429 is not called again for the rest of the batch. Those chunks count as failed, so the batch is requeued.
Test plan
- New unit tests: the drain claims once and stops after a failed batch; a 429 zone is called once per batch.
-
bun run test:unit(678 files, 8,187 tests),bun run typecheck:backend,bun run lint:backend - CI
- After deploy:
updates_cache_purge_pendingdrains, and 429 logs drop.
No rendered UI changes, so there are no screenshots.
š¤ Generated with Claude Code