-
Notifications
You must be signed in to change notification settings - Fork 2.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 infinite get route request #45579
Fix infinite get route request #45579
Conversation
@thesahindia Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
const validatedWaypoints = TransactionUtils.getValidWaypoints(waypoints); | ||
const previousValidatedWaypoints = usePrevious(validatedWaypoints); | ||
const haveValidatedWaypointsChanged = !isEqual(previousValidatedWaypoints, validatedWaypoints); | ||
const isRouteAbsentWithoutErrors = !hasRoute && !hasRouteError; | ||
const isEmptyCoordinates = !transaction?.routes?.route0?.geometry?.coordinates?.length; | ||
const shouldFetchRoute = (isEmptyCoordinates || isRouteAbsentWithoutErrors || haveValidatedWaypointsChanged) && !isLoadingRoute && Object.keys(validatedWaypoints).length > 1; |
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.
@thesahindia @neil-marcellini While working on this other PR, I found an issue from our PR #45139. When the selected waypoints are invalid (gives an error), it will result in an infinite request of GetRoute.
web_error.mp4
So, my first thought is to only re-fetch the route if there is no error. Then, I saw that we already have that kind of logic, the isRouteAbsentWithoutErrors
.
hasRoute
also checks for the route coordinate, but it also checks for customUnit.quantity
if isDistanceRequestType
.
App/src/libs/TransactionUtils.ts
Lines 576 to 578 in 52b8fdd
function hasRoute(transaction: OnyxEntry<Transaction>, isDistanceRequestType: boolean): boolean { | |
return !!transaction?.routes?.route0?.geometry?.coordinates || (isDistanceRequestType && !!transaction?.comment?.customUnit?.quantity); | |
} |
Because hasRoute
is only used to re-fetch the routes, I decided to remove isEmptyCoordinates
and pass nothing to isDistanceRequestType
param.
Reviewer Checklist
Screenshots/VideosAndroid: NativeScreen.Recording.2024-07-17.at.11.52.08.PM.movAndroid: mWeb ChromeScreen.Recording.2024-07-17.at.11.56.39.PM.moviOS: NativeScreen.Recording.2024-07-18.at.12.15.10.AM.moviOS: mWeb SafariScreen.Recording.2024-07-18.at.12.12.42.AM.movMacOS: Chrome / SafariScreen.Recording.2024-07-17.at.11.38.23.PM.movMacOS: DesktopScreen.Recording.2024-07-17.at.11.42.03.PM.mov |
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.
Thanks for the changes!
@thesahindia, |
Oh, thanks for pointing that out. I'll get some help. |
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.
Thanks for a quick fix, going to merge this as Neil is ooo until Monday
🚀 Deployed to staging by https://github.com/mountiny in version: 9.0.10-2 🚀
|
🚀 Cherry-picked to staging by https://github.com/mountiny in version: 9.0.10-3 🚀
@Expensify/applauseleads please QA this PR and check it off on the deploy checklist if it passes. |
🚀 Deployed to production by https://github.com/mountiny in version: 9.0.10-7 🚀
|
🚀 Deployed to production by https://github.com/francoisl in version: 9.0.11-5 🚀
|
Thanks for the quick fix while I was out! |
Details
It was caused by #45139 where we refetch the routes when the coordinate is empty, but it will result in an infinite request if the routes has an error.
Fixed Issues
$ #44156
PROPOSAL:
Tests
Same as QA Steps
Offline tests
Same as QA Steps
QA Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
android.mp4
Android: mWeb Chrome
iOS: Native
ios.mp4
iOS: mWeb Safari
ios.mweb.mp4
MacOS: Chrome / Safari
web.mp4
MacOS: Desktop
desktop.mp4