-
Notifications
You must be signed in to change notification settings - Fork 273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: token list exception #927
Merged
Merged
Conversation
This file contains 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
chore: add dev ui chore: ignore empty object error chore: comment
simonheys
force-pushed
the
bugfix/token-list-exception
branch
from
July 8, 2022 15:35
2beddb2
to
68beaae
Compare
simonheys
commented
Jul 8, 2022
simonheys
commented
Jul 8, 2022
|
||
// shallow compare objects and arrays | ||
const tokensInNetwork = useTokens(tokensInNetworkSelector, shallow) | ||
const tokenAddresses = useTokens(tokenAddressesSelector, shallow) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mix of memoized selectors and shallow compare should prevent new-but-same-array-of-tokens from triggering re-render
janek26
reviewed
Jul 8, 2022
simonheys
force-pushed
the
bugfix/token-list-exception
branch
from
July 10, 2022 15:13
005a6a4
to
46b1db5
Compare
janek26
approved these changes
Jul 11, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good
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.
Fixes (for me) issues with the token list vs error handling.
Root cause was a mix of swr suspense, and an issue with caching an error as an empty object. The suspense implementation was using a possibly undefined key (not allowed in suspense[1]) and returning empty data with a cached error (also not allowed in suspense[1]).
This causes an unrecoverable swr suspense error - reloading the component retrieves the same error from the cache. The error gets written to the cache at some point when reloading the extension, so reloading does not resolve it either. I was not able to identify where the empty object originates as it happens while reloading the extension and the debugger is closed.
I chose to always show the first token 'ETH' while the others are still initially loading as it made the app feel more responsive, however this could be changed to hide all until fetched. Previously no loading state was shown as the first token resolved the suspense immediately.
Some zustand selectors were memoized and shallow compare added to reduce chance of re-renders.
Adds
yarn dev:ui
which adds permanent 'reload' and 'Reset cache' buttons to the extension window.[1] vercel/swr#357 (comment)
dev-ui.mov