feat(backend): add retry queue for failed recordPaymentOnChain calls#197
feat(backend): add retry queue for failed recordPaymentOnChain calls#197leocagli wants to merge 1 commit into
Conversation
Closes Stellar-Ecosystem#129 recordPaymentOnChain was called fire-and-forget with .catch(warn) — transient RPC failures silently dropped agent score updates, causing score drift between on-chain state and reality with no recovery path. Changes: - Added backend/src/lib/paymentRetryQueue.js: an in-memory queue with exponential backoff (5s → 80s, max 5 attempts) driven by a 5s interval (unref'd so it does not block process exit) - services.js weather handler: on first failure, logs a warning and enqueues via enqueuePaymentRecord() for automatic retry - services.js search handler: same pattern The queue is in-process only (lost on restart). This handles the common transient failure case (RPC hiccup, timeout) without the complexity of SQLite/file persistence. Permanent failures after MAX_ATTEMPTS are logged at error level with full context for operator alerting.
|
Warning Review limit reached
More reviews will be available in 49 seconds. Learn how PR review limits work. To continue reviewing without waiting, enable usage-based billing in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Closes #129
Summary
recordPaymentOnChainin both weather and search handlers was called fire-and-forget with.catch(warn)— a transient RPC failure silently dropped agent score updates, causing score drift between on-chain state and reality with no recovery path.backend/src/lib/paymentRetryQueue.js(new): in-memory queue with exponential backoff (5s → 10s → 20s → 40s → 80s, max 5 attempts). A 5ssetIntervalworker (unref'd so it does not block process exit) processes due entries.services.js: weather and search handlers now callenqueuePaymentRecord(agentAddress, fn)in their catch block instead of silently discarding the failure.errorlevel with full context for operator alerting.The queue is in-process only — lost on restart. This handles the common transient failure case (RPC hiccup, network timeout) without SQLite/file persistence complexity.
Test plan
recordPaymentOnChainto fail 3 times then succeed — verify the retry queue succeeds on the 4th attempt