Stop refetching tokens without a price source on every block#56
Merged
Conversation
Same retry-storm bug we fixed in d-EURO API (PR d-EURO#112): when fetchPrice() returns no usd value (e.g. an unlisted collateral token where CoinGecko returns {}), updatePrices() left the cache entry untouched and the 5-minute staleness check (timestamp + 300_000 < now) was still true on the next block tick. Combined with the 10 s block polling that drives updatePrices(), this made the same handful of unlisted tokens generate a steady upstream MISS on every cycle, leaking through the pricing-proxy's 60 s cache once per minute per token. Bump the entry's timestamp on a failed fetch too, so the retry honours the same 5-minute window as a successful fetch.
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
Mirror of the d-EURO API fix in d-EURO/api#112. The two services share the same
updatePrices()shape and the same defect:fetchPrice()returns nousdvalue (e.g. CoinGecko returns{}for an unlisted collateral token, sofetchSourcesCoingecko()yieldsundefined),updatePrices()discards the result without touching the cache entry.timestampnever advances,oldEntry.timestamp + 300_000 < Date.now()stays true and the same token is retried on every block tick (every 10 s viaApiService.updateBlockheight).timestampon a failed fetch as well, so a missing price obeys the same 5-minute retry window as a successful one.Test plan
yarn buildsimple/token_price/ethereum?contract_addresses=…for unlisted-token addresses drops from ~50/h to ~12/hGET /prices/liststill lists those tokens (without a meaningfulprice.usd, as before)