Skip to content

improve(PriceClient): Gracefully fallback when price feed queries fail#1293

Open
nicholaspai wants to merge 1 commit intomasterfrom
price-feed-client-default
Open

improve(PriceClient): Gracefully fallback when price feed queries fail#1293
nicholaspai wants to merge 1 commit intomasterfrom
price-feed-client-default

Conversation

@nicholaspai
Copy link
Copy Markdown
Member

  • acrossApi.ts: Return undefined for a specific token price query if unavailable rather than throwing if any individual query fails
  • priceClient.ts: When falling back to the next priceFeed, only query token addresses that we don't have a price for. This allows the priceFeed. getPricesByAddress() to "partially resolve", like in the case when querying the Across API via the acrossApi adapter.

- `acrossApi.ts`: Return undefined for a specific token price query if unavailable rather than throwing if any individual query fails
- `priceClient.ts`: When falling back to the next `priceFeed`, only query token addresses that we don't have a price for. This allows the `priceFeed. getPricesByAddress()` to "partially resolve", like in the case when querying the Across API via the `acrossApi` adapter.
@nicholaspai nicholaspai requested review from bmzig and pxrl November 25, 2025 00:34
@nicholaspai
Copy link
Copy Markdown
Member Author

@codex

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 36fe897f4b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +132 to +133
// Only request prices for addresses that are not already in the price cache.
const _addrsToRequest = addrsToRequest.filter((address) => !priceCache[address.toLowerCase()]);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P0 Badge Request missed tokens instead of filtering them out

PriceClient#getPricesByAddress writes a placeholder entry into priceCache for every miss before it calls updatePrices(), so priceCache[address.toLowerCase()] is always truthy for every token that actually needs fetching. This new filter therefore turns _addrsToRequest into [] on every first lookup and every expired lookup, meaning no adapter is queried, updateCache() sees no expected tokens, and callers get the placeholder { price: 0, timestamp: 0 } back instead of a real price or an error. That makes cache misses fail silently for all consumers, not just the partial Across-API case this patch is targeting.

Useful? React with 👍 / 👎.

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