-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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 parallel calls for quotes in swaps #12484
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. |
return [ | ||
{}, // quotes | ||
null, // selectedAggId | ||
]; | ||
} | ||
this.setIsFetchingQuotes(false); |
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.
Why is this line removed?
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.
This line was the problem if 2 calls are being made in parallel. Both of them set it to true before the API call, then when the first one finished, it set it to false and when the second one finished, it was already false, so we returned empty quotes and showed the "No quotes found" page. Without this line 2 parallel calls work correctly.
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.
but what is the consequence of never setting it to false? was this needed before?
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.
should we use this.indexOfNewestCallInFlight === indexOfCurrentCall
to determine whether to call this.setIsFetchingQuotes(false);
if (this.indexOfNewestCallInFlight === indexOfCurrentCall) {
this.setIsFetchingQuotes(false);
}
This would ensure that this.setIsFetchingQuotes(false);
still gets called, but not if there is another call happening in parallel.
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.
Now it's only set to false
from initialState
when a user leaves Swaps. We don't really need to set it to false
here. However, I've used the code you suggested and it works well with it, so I've already included it in this PR.
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.
LGTM
…oring" This reverts commit a5e69d2.
Description
Sometimes our UI triggered 2 API calls for quotes in parallel, which resulted in "No quotes found" page. This PR fixes it.