fix: trying to access an undefined object in swaps review quote compo…#27708
fix: trying to access an undefined object in swaps review quote compo…#27708
Conversation
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
05ab643 to
eac5c27
Compare
eac5c27 to
05c0651
Compare
| const latestAddedTokenTo = useSelector(getLatestAddedTokenTo, isEqual); | ||
| const numberOfQuotes = Object.keys(quotes).length; | ||
| const areQuotesPresent = numberOfQuotes > 0; | ||
| const areQuotesPresent = numberOfQuotes > 0 && usedQuote; |
There was a problem hiding this comment.
Two questions, possibly not worth digging into right now but things we could consider trying to straighten out in the future:
(1) What's the reason usedQuote may not exist if numberOfQuotes > 0?
(2) Is numberOfQuotes > 0 adding anything here or would we just want to use the presence/absence of usedQuote?
There was a problem hiding this comment.
Yea for sure, good questions:
1.
This is what I touched on a bit in the PR description usedQuote is derived from getSelectedQuote or getTopQuote, which both use a key to access the quotes object selectedAggId or topAggId. After many changes, there is a single or a couple of render cycles where this is quotes are defined, but usedQuote is not. usedQuote should never be undefined if quotes are defined, but that does not seem to be true always, which is the root cause of this bug. I tried finding out why, but it took me deep into the extension redux setup, which I'm not too familiar with. That's why I opted for a more bandaid fix like this
2.
I think we could probably remove the length check here, but since the checks accomplish similar things to usedQuote and I'd rather minimize the changes required for the PR, I decided to keep it in. If you think it's worth keeping the checks simpler, I can try it out though!
There was a problem hiding this comment.
Let's keep it in for now - no harm in it 🤷
|
Builds ready [7f128cf]
Page Load Metrics (2095 ± 140 ms)
Bundle size diffs
|



Description
Fixes the two errors with trade and decimals being undefined that have been causing crashes starting around the 12.1/12.2 release. I was unable to find the root cause of this issue. Variables in the redux store seem to return as undefined, which leads me to think it might be some sort of redux race condition. The lowest common denominator of this error seems to be that
getUsedQuoteselector in theReviewQuotecomponent. I have added an additional condition to the render guard in the parent componentprepare-swaps-pageto prevent these errorsRelated issues
MMS-1569
Manual testing steps
Pre-merge author checklist
Pre-merge reviewer checklist