fix(quoter-bot): retry transient provider reads with backoff - #168
Merged
Conversation
haydenshively
marked this pull request as ready for review
September 4, 2026 03:32
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1699bf7f00
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
haydenshively
force-pushed
the
fix/quoter-bot-provider-read-retry
branch
from
September 4, 2026 03:53
1699bf7 to
3e3e50b
Compare
haydenshively
enabled auto-merge (squash)
September 4, 2026 04:21
cashd
approved these changes
Sep 4, 2026
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.
Incident
The production quoter bot on Railway safety-halted 7 times in ~24 hours (2026-08-14 14:21 → 2026-08-15 13:42 UTC), and the final halt left the deployment
CRASHEDwith all offers cancelled. Every halt had the same shape: a single transientSafeProviderErroron a read-only HTTP GET (requestJsonagainst the morpho-api/router-api endpoints) surfaced in a ladder/bootstrap cycle read, and the workflow's safety halt cancelled the resting ladder on-chain and exited the process. The bot ran 210+ clean 60s cycles between failures — intermittent API flakiness (roughly one blip every ~4 hours), each costing on-chain cancel gas and full downtime until restart.Fix
Add retry-with-backoff for transient provider failures at the HTTP transport seam, so one blip no longer triggers the safety halt while genuine/persistent failures still do.
retryTransientProviderReadutility (bots/quoter-bot/src/infrastructure/setup-state/provider-retry.utils.ts);requestJsonnow wraps a single-shotattemptJsonin it. All these requests are idempotent read-only GETs, so repetition is safe.SafeProviderErrorwithnameTimeoutError/NetworkError, or HTTP status 408/429/5xx.SafeProviderErrorthrow — rethrown immediately.capped/2 + random·capped/2wherecapped = min(4000ms, 500ms·2^(n-1))) → worst-case ~1.5s added latency, well inside the 60s cycle interval.SafeProviderErroris rethrown unchanged — no new error type, no URL or response body ever touched, so downstream halt behavior and operator-visible reports are identical.delayfrom@repo/utils. Evidence for the local utility:retryUntilDefinedin@repo/utilshas a sync predicate and no backoff/classification;@repo/bot-kit'screateBackoffis block-height keyed for the tx queue — neither matches.Tests
provider-retry.utils.test.ts(new, 12 tests, fake timers): retries each transient class then succeeds; no retry on 400/403/404 or non-provider errors; exhausts 3 attempts and rethrows the final sanitized error with metadata intact; backoff bounds verified at both jitter extremes.viem-setup-state.service.test.ts: 2 loopback-server integration tests (503×2 then success; 400 not retried).Validation
typecheck✅ ·pnpm lint✅ (0 warnings) ·pnpm format✅ ·pnpm test✅ (1865 passed / 12 skipped; only pre-existing env-gated fork/e2e failures needingRPC_URL_8453+ anvil) ·jsdoc:build✅ ·knip✅ (via pre-commit)Follow-ups (deliberately out of scope)
provider-read.utils.ts/ProviderReadError): left alone — viem'shttp()transport already retries (defaultretryCount: 3, exponential backoff) beneath these reads; wrapping again would multiply attempts.errorName, dropping the sanitizedfailuremetadata (provider/status/code) that would have made this incident diagnosable from logs alone. Threading it throughLadderVerboseStateripples across several typed call sites — worth its own PR.🤖 Generated with Claude Code