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 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.
@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
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 |
|
@thesahindia, |
Oh, thanks for pointing that out. I'll get some help. |
mountiny
left a comment
There was a problem hiding this comment.
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 Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.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