Skip to content

fix(liquidity): bound external balance fetches with timeouts#3905

Open
TaprootFreak wants to merge 1 commit into
developfrom
fix/balance-fetch-timeouts
Open

fix(liquidity): bound external balance fetches with timeouts#3905
TaprootFreak wants to merge 1 commit into
developfrom
fix/balance-fetch-timeouts

Conversation

@TaprootFreak

Copy link
Copy Markdown
Collaborator

Problem

A single hung integration.getBalances() froze the entire liquidity-balance refresh: refreshBalances awaits all integrations via Promise.allSettled, which never resolves if one promise never settles. The central HttpService set no axios timeout, so a raw HTTP call (e.g. a bank API holding the connection open without responding) could hang indefinitely → all liquidity balances stayed frozen for hours, and the financial-data-log total ran on stale balances (plus side frozen while order-derived minus kept moving → valid=false, overstated total).

Fix (two layers)

  1. Source — default HTTP timeout: HttpModule.register({ timeout: 60_000 }). Every central-HttpService call is now bounded; per-request config.timeout still overrides. ccxt exchanges are unaffected (own 30s timeout).
  2. Backstop — per-integration timeout in refreshBalances: each getBalances() is wrapped in Util.timeout(..., 120_000) (deliberately longer than the 60s HTTP timeout, so HTTP hangs are caught fine-grained at the source and only genuine non-HTTP hangs hit the backstop). A timed-out integration rejects → Promise.allSettled drops only it → the other integrations still save.

Avoiding regressions

Slow backoffice/cron HTTP calls that legitimately may exceed 60s get an explicit generous timeout: 180_000 so the new global default cannot truncate them: App Insights KQL, Sumsub, Dilisense, Yapeal statement/CAMT retrievals.

Validation

type-check, lint, format:check all pass.

A single hung integration.getBalances() froze the entire liquidity balance
refresh (Promise.allSettled waits for all), leaving every balance stale for
hours. Add two layers: a default 60s timeout on the central HttpService so raw
HTTP calls can no longer hang indefinitely, and a 120s per-integration backstop
in refreshBalances for non-HTTP hangs. Slow backoffice/cron calls (App Insights
KQL, Sumsub, Dilisense, Yapeal statements) get explicit generous timeouts so the
new default does not truncate them.
@TaprootFreak TaprootFreak marked this pull request as ready for review June 17, 2026 08:56
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.

1 participant