Retry Bungie Cloudflare blocks via queue backoff - #76
Merged
Conversation
…messages. Use one quick in-process CF retry (~2s with jitter) and two transient retries per request, then republish failed crawl messages indefinitely on the delayed exchange (30m cap) so workers are not blocked during long Cloudflare outages. Co-authored-by: Cursor <cursoragent@cursor.com>
6 tasks
Comment on lines
103
to
105
| queryValues := url.Query() | ||
| queryValues.Add("retry", fmt.Sprintf("%d", attempt)) | ||
| url.RawQuery = queryValues.Encode() |
There was a problem hiding this comment.
Bug: The condition if attempt > 1 is unreachable because the retry logic is configured with MaxAttempts: 1, making the code to add a retry query parameter dead.
Severity: LOW
Suggested Fix
Either remove the unreachable if attempt > 1 block to eliminate the dead code, or if the retry query parameter is desired for observability, increase the MaxAttempts value in the CloudflareRetryConfig to be greater than 1.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: lib/web/bungie/client.go#L103-L105
Potential issue: In the retry logic for Bungie API requests, a condition `if attempt >
1` is used to add a `retry` query parameter to the URL. However, the underlying retry
mechanism is configured with `MaxAttempts: 1`. This configuration means the function
will be called with `attempt = 0` on the first try and `attempt = 1` on the single retry
attempt. The `attempt` variable will never be greater than 1, making the conditional
block unreachable dead code. This results in a minor loss of observability, as the
intended debugging parameter will never be added.
Did we get this right? 👍 / 👎 to inform future reviews.
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
MaxRetryCount: 0on Bungie crawl queues (player_crawl,character_fill,activity_history,clan_crawl) so transient CF blocks republish to the delayed exchange with exponential backoff (capped at 30m) instead of being dropped after 3–5 attempts.Addresses recurring SERVICES-1Q (
MESSAGE_EXCEEDED_MAX_RETRIESon Bungie 403 Cloudflare pages).Test plan
go build ./...make hermes && sudo systemctl restart hermesMESSAGE_EXCEEDED_MAX_RETRIESstops forplayer_crawl/character_fillduring CF blipsDeploy
Manual Hermes restart on prod after merge.
Made with Cursor