wip(bridge): keep lifi token registry under 2MB#406
Closed
dewanshparashar wants to merge 4 commits into
Closed
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
dewanshparashar
marked this pull request as ready for review
July 16, 2026 10:53
Contributor
There was a problem hiding this comment.
Pull request overview
This PR reduces the size of the cached LiFi token registry to stay under Next.js’ 2MB unstable_cache item limit, preventing cache-write failures that currently force every request to refetch the full LiFi token universe.
Changes:
- Cache only
tokensByChainand rebuildtokensByChainAndCoinKeyon read to avoid duplicated data. - Strip unused token metadata fields to shrink the serialized cache payload.
- Prune tokens whose
coinKeydoes not exist on any partner chain (with an ApeChain ETH↔WETH routing exception) to remove non-routable tokens.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
263
to
265
| if (!response.tokens) { | ||
| return { | ||
| tokensByChain: {}, | ||
| tokensByChainAndCoinKey: {}, | ||
| }; | ||
| return {}; | ||
| } |
Comment on lines
+212
to
+218
| /** | ||
| * Tokens are matched across chains by coinKey (see groupChildTokensAndParentTokens), | ||
| * so a token whose coinKey doesn't exist on any partner chain can never appear | ||
| * in a route and only bloats the cache. LiFi returns thousands of such tokens | ||
| * (e.g. Ethereum-only meme tokens). | ||
| */ | ||
| function keepRoutableTokens( |
Contributor
Author
|
Superseded by #407, which carries this fix as one of its three commits. |
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.
The serialized lifi token registry is ~2.6MB, over Next.js' 2MB
unstable_cacheitem limit. Every cache write fails (Failed to set Next.js data cache ... items over 2MB can not be cached), so every request to/api/crosschain-transfers/lifi/tokensrefetches the full token universe from li.quest. On CI runners this takes longer than the import E2E test's 30s window, which is why the Import test jobs fail on every PR. It also slows down token search for real users.This shrinks the cached value from ~2.6MB to ~170KB (6.6%):
tokensByChainand rebuild thetokensByChainAndCoinKeylookup on read — the lookup duplicates almost every token.Verified against live li.quest data that the route output is identical for all 25 supported chain pairs before/after.