Skip to content

fix(plugin): stop the cache purge drain on a rate-limited batch - #4303

Merged
riderx merged 2 commits into
mainfrom
fix/purge-drain-stop-on-429
Dec 1, 2026
Merged

riderx merged 2 commits into
mainfrom
fix/purge-drain-stop-on-429

Conversation

@riderx

@riderx riderx commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

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_pending drains, and 429 logs drop.

No rendered UI changes, so there are no screenshots.

🤖 Generated with Claude Code

View guided diff Turn on auto-fix

When Cloudflare rate-limited a purge batch, the drain requeued it at its
Retry-After and immediately claimed the next batch, so concurrent drains
cycled through the whole queue every few seconds and kept the purge quota
spent: in prod thousands of 429s a minute and no purge got through. The drain
now stops after a failed batch, and a zone that answered 429 is not called
again for the rest of the batch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@riderx
riderx deployed to deepsec-pr December 1, 2026 07:03 — with GitHub Actions Active
@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 18 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 42074e88-9442-42a6-922f-0c5a8a12b4d7
Commits

Reviewing files that changed from the base of the PR and between 83f1a59 and 94abf63.

Files selected for processing: 2

  • supabase/functions/_backend/triggers/updates_cache_purge.ts
  • tests/updates-edge-cache.unit.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-01T07:15:04.686773Z 94abf63 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@codspeed

codspeed Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 43 untouched benchmarks
⏩ 2 skipped benchmarks1


Comparing fix/purge-drain-stop-on-429 (94abf63) with main (83f1a59)

Open in CodSpeed

Footnotes

  1. 2 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@riderx

riderx commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@riderx
riderx deployed to deepsec-pr December 1, 2026 07:13 — with GitHub Actions Active
@sonarqubecloud

sonarqubecloud Bot commented Dec 1, 2026

Copy link
Copy Markdown

@riderx

riderx commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@riderx
riderx merged commit a46dd54 into main Dec 1, 2026
80 checks passed
@riderx
riderx deleted the fix/purge-drain-stop-on-429 branch December 1, 2026 07:21

This branch was successfully deployed

1 active deployment
deepsec-pr — 94abf63c Deployed Dec 1, 2026 by riderx via Scan PR changes #12330
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant