Skip to content

docs(r2): describe R2's 503 as ServiceUnavailable, not a rate limit - #249

Merged
flyq merged 1 commit into
mainfrom
liquan/doc/r2-503-service-unavailable
Nov 27, 2026
Merged

flyq merged 1 commit into
mainfrom
liquan/doc/r2-503-service-unavailable

Conversation

@flyq

@flyq flyq commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Corrects the R2Error::Throttled and R2GetError::Throttled doc comments in stateless-r2, which called 503 "R2's 503 overload / SlowDown".
  • Cloudflare documents exactly one R2 503 code, 10043 ServiceUnavailable: "Service is temporarily unavailable", with the fix "Retry with exponential backoff". R2's rate limit is 429 10058 TooManyRequests (for example, more than 1 write per second to the same key). SlowDown is AWS S3's throttling code and does not appear in R2's error-code tables.
  • The Throttled doc now also says that only a 429 reflects the client's own load. A caller that pauses all of its requests, rather than backing off the one that failed, should decide that from status, not from the variant.
  • The two retry tests whose 503 mock answered SlowDown now answer ServiceUnavailable, so the fixtures match what R2 actually returns.

No behavior change: is_throttle_status still treats 429 and every 5xx as backoff-worthy.

Why

The replay witness uploader writes through this crate. It took the old wording at face value and treated a 503 as a rate limit, pausing every upload for 30 seconds. On testnet, two single 503s stopped witness uploads for about 30 seconds each, and the stateless validator stalled for 37 s and 43 s while it waited for those witnesses. The uploader fix is a separate PR in mega-reth.

References: https://developers.cloudflare.com/r2/api/error-codes/ , https://developers.cloudflare.com/r2/platform/limits/

Testing

  • cargo test -p stateless-r2 (55 passed)
  • cargo clippy -p stateless-r2 --all-targets --all-features, cargo fmt --all --check

🤖 Generated with Claude Code

R2 documents exactly one 503 code, ServiceUnavailable ("Service is
temporarily unavailable", retry with exponential backoff). Its rate
limit is 429 TooManyRequests, and SlowDown is AWS S3's code, not R2's.
The R2Error/R2GetError docs called 503 "R2's overload / SlowDown",
which the witness uploader took as a rate-limit signal.

Correct both doc comments, note that only a 429 says anything about
the client's own load, and make the 503 test mocks answer
ServiceUnavailable. Classification is unchanged: 429 and every 5xx
remain backoff-worthy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mega-maxwell

mega-maxwell Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Claude review status

Living comment — rewritten in place. The review workflow keeps this single comment up to date instead of posting a new one each round, so it always describes the latest reviewed commit and the earlier text is intentionally gone. No reply is needed here; reply to a finding in its own review thread, and answer an open question in a reply on this PR. The next review round reconciles your answer.

✅ Review clean

Last reviewed: head 718abb43 · updated 2026-11-26T07:54:26+00:00

New this round: 0 finding(s), 0 question(s) · Resolved this round: 0 · Open questions: 0

@claude

claude Bot commented Nov 26, 2026

Copy link
Copy Markdown

This PR currently has no labels, but it should have at least:

  • documentation — the entire change is a doc-comment correction (R2Error::Throttled / R2GetError::Throttled doc comments and their test fixtures), with no logic change. The PR body itself states "No behavior change."
  • compat:seamless — there's no API/RPC change (is_throttle_status behavior is unchanged) and no CLI/config change, so this doesn't need external notification per compat:interface/compat:config.

None of the other labels (bug, enhancement, compat:interface, compat:config, etc.) apply here.

@flyq
flyq merged commit 398198e into main Nov 27, 2026
22 checks passed
@flyq
flyq deleted the liquan/doc/r2-503-service-unavailable branch November 27, 2026 07:09
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.

3 participants