feat(backend): harden reliability — timeouts, circuit-breaker, retry,… - #1437
Merged
Akanimoh12 merged 1 commit intoAug 28, 2026
Conversation
… payload limits - Add explicit timeouts for all outbound HTTP (Soroban RPC, Horizon, IPFS, X API) via fetchWithTimeout / withTimeoutAndSignal; timeouts are configurable through env (SOROBAN_RPC_TIMEOUT_MS, HORIZON_TIMEOUT_MS, IPFS_TIMEOUT_MS, X_API_TIMEOUT_MS) and merged with client-disconnect AbortSignal (req.signal) - Server-level request timeout middleware (REQUEST_TIMEOUT_MS, default 30s) returns 503 REQUEST_TIMEOUT and aborts in-flight upstream work; client close also aborts via AbortSignal - Extract X circuit breaker into shared utility src/common/utils/circuitBreaker.ts; re-export from x.circuit-breaker.ts so x.circuit-breaker.test.ts passes unmodified; apply breaker to RPC (Soroban) and Horizon with fast-fail 503 SERVICE_UNAVAILABLE, logging and metrics exposure via /metrics (circuitBreaker states, timeouts) - Standardise retry in src/common/utils/retry.ts with exponential backoff + full jitter, non-retryable 4xx / non-idempotent guard, configurable ceiling, logged attempts; indexer/retry.ts re-exports shared implementation for backward compat - Right-size payload limits: default JSON 100kb (configurable JSON_BODY_LIMIT, down from 1mb), per-route larger 500kb for /tips /profiles /auth, multer files:1 fields:10 fileSize 5MB; oversized bodies mapped to 413 PAYLOAD_TOO_LARGE in errorHandler instead of HTML Closes Akanimoh12#90, Akanimoh12#91, Akanimoh12#92, Akanimoh12#77
|
@Chidubemkingsley Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
closes Add request timeout and cancellation handling #1237
closes Add circuit breakers for Soroban RPC and Horizon #1238
closes Add retry with jitter for transient upstream failures #1239
closes Add request body size limits per route #1224
Add explicit timeouts for all outbound HTTP (Soroban RPC, Horizon, IPFS, X API) via fetchWithTimeout / withTimeoutAndSignal; timeouts are configurable through env (SOROBAN_RPC_TIMEOUT_MS, HORIZON_TIMEOUT_MS, IPFS_TIMEOUT_MS, X_API_TIMEOUT_MS) and merged with client-disconnect AbortSignal (req.signal)
Server-level request timeout middleware (REQUEST_TIMEOUT_MS, default 30s) returns 503 REQUEST_TIMEOUT and aborts in-flight upstream work; client close also aborts via AbortSignal
Extract X circuit breaker into shared utility src/common/utils/circuitBreaker.ts; re-export from x.circuit-breaker.ts so x.circuit-breaker.test.ts passes unmodified; apply breaker to RPC (Soroban) and Horizon with fast-fail 503 SERVICE_UNAVAILABLE, logging and metrics exposure via /metrics (circuitBreaker states, timeouts)
Standardise retry in src/common/utils/retry.ts with exponential backoff + full jitter, non-retryable 4xx / non-idempotent guard, configurable ceiling, logged attempts; indexer/retry.ts re-exports shared implementation for backward compat
Right-size payload limits: default JSON 100kb (configurable JSON_BODY_LIMIT, down from 1mb), per-route larger 500kb for /tips /profiles /auth, multer files:1 fields:10 fileSize 5MB; oversized bodies mapped to 413 PAYLOAD_TOO_LARGE in errorHandler instead of HTML
Closes #90, #91, #92, #77
Description
Closes #
Type of Change
Please mark the options that are relevant:
Changes Made
How to Test
Checklist
💻 Smart Contract Changes (if applicable)
cargo fmt -- --checkpasses successfully.cargo clippy -- -D warningsruns without any warnings.cargo test.🎨 Frontend Changes (if applicable)
npm run typecheckornpx tsc --noEmit).npm run lintshows no linting errors.npm run build.⚙️ General
console.logor debug code remains in production files.mainbranch.Screenshots / Demos (if applicable)