Repository navigation
feat: rate-limit personalization and retry preview 503s - #26
Merged
Merged
Conversation
Generalize the cache-miss limiter into rateLimit.ts with separate namespaces. /api/preview keeps its 20/min bucket; cache-miss /api/personalize requests now get a 10/min bucket before any embedding or LLM polish work. Cache hits bypass both. Personalize 429s log personalize_rate_limited and return Retry-After: 60. Retry a preview request once after a 503 (Cloudflare CPU limit) with a 500ms delay. Do not retry 429s, whose Retry-After is 60 seconds. Bump app.js to v110 and the PWA shell cache to v144. Co-Authored-By: Claude Code <noreply@anthropic.com>
|
🔎 Cloudflare preview: https://4f61938f-feedreader.phatpham9.workers.dev Uploaded from |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two remaining AI/UX hardening items:
rateLimit.tswith separate namespaces./api/previewkeeps its 20/min bucket; cache-miss/api/personalizerequests now get a 10/min bucket before any embedding or LLM polish work. Cache hits bypass both. A blocked personalization request returns429withreason: "rate_limited"/Retry-After: 60and logspersonalize_rate_limited(no interests or IPs logged).503with a 500ms delay.429s are not retried because the limiter’sRetry-Afteris 60 seconds.app.jstov110and the PWA shell cache tov144.Verification
npm run typechecknpx vitest run --exclude '.claude/**'— 18 files, 147 testsnode --check web-static/static/app.jsnpm run db:migrate:localwrangler deploy --dry-run— 372.97 KiB / 98.93 KiB gzip429in 4–7ms withreason: "rate_limited"and loggedpersonalize_rate_limited.200/ 12 blocks and a personalization request returned200/llm.Notes
🤖 Generated with Claude Code