Skip to content

Handle concurrent kv writes for token refresh - #666

Closed
cursor[bot] wants to merge 1 commit into
mainfrom
error-kv-put-i5n4rl
Closed

cursor[bot] wants to merge 1 commit into
mainfrom
error-kv-put-i5n4rl

Conversation

@cursor

@cursor cursor Bot commented Dec 3, 2025

Copy link
Copy Markdown
Contributor

Add retry logic to Cloudflare KV put operations for OAuth grant keys to prevent 429 errors during concurrent token refreshes.

Concurrent OAuth token refresh attempts can lead to multiple writes to the same Cloudflare KV grant key within a second. Cloudflare KV enforces a strict 1 write/second limit per key, causing subsequent writes to fail with a "429 Too Many Requests" error. This change introduces a retry mechanism with a linear backoff specifically for grant: keys, allowing the second attempt to succeed after a short delay, thus serializing the writes and preventing the error.


Open in Cursor Open in Web

Implement retry logic for KV writes to handle rate limiting on grant updates.

Co-authored-by: jenn.muengtaweepongsa <jenn.muengtaweepongsa@sentry.io>
@cursor

cursor Bot commented Dec 3, 2025

Copy link
Copy Markdown
Contributor Author

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@JoshFerge JoshFerge closed this Dec 3, 2025
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.

2 participants