fix(fx): keep exchange rates warm and decouple the failure cooldown from the timeout - #220
Merged
Merged
Conversation
…eout Launch currencies now refresh on a ~30s schedule instead of relying on demand-driven fetches, so a hot path holding a lock (RG limit gate, rank accrual, a P2P transfer) never falls through to a synchronous vendor call. A failed vendor call previously cooled down for exactly providerTimeoutMs, so an outage added a full timeout stall to every call for its duration. The cooldown is now its own failureCooldownMs config, defaulting well above the timeout. useExchangeRate/useExchangeRates now set staleTime: 60_000 and refetchOnWindowFocus: false, matching the reader's own fresh window.
zaxovaiko
requested review from
damianrzepka,
jakubfilinger-b,
klaudia-blazyczek-blurify,
marek-chmielowski-blurify,
mp-blurify and
okapitula
as code owners
September 24, 2026 21:54
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
Keeps configured exchange rates warm on a 30s schedule, gives the failure cooldown its own
exchangeRate.failureCooldownMsknob (default 30s), and stopsuseExchangeRate(s)refetching inside the fresh window. BF-0Why
providerTimeoutMson the vendor.providerTimeoutMs, so during an outage almost every call waited out the timeout again.staleTime, so every mount and window refocus refetched a rate the server still considered fresh.The warm-up reuses the existing
getRatepath and job-queue pattern (same shape as the wallet sweep cron): everywallet.cryptoCurrenciesentry plus display currencies, minus the pivot, bounded at 4 concurrent fetches, per-currency failures logged and swallowed.Alternatives considered
hardMaxAgeMsonly: hides the stall but serves older prices to limit checks.Risks