-
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
[Crashlytics] TypeError: Cannot read property 'routes' of undefined #46118
Comments
Current assignee @CortneyOfstad is eligible for the Bug assigner, not assigning anyone new. |
@CortneyOfstad Eep! 4 days overdue now. Issues have feelings too... |
@TMisiukiewicz it was indicated on one of the other Crashlytic GHs that the logs are truncated. Any way you could pull up the full logs? Thanks! |
I tried following the breadcrumbs from firebase, but couldn't reproduce it. Looks like when using system back button on Android, sometimes We could prevent crashing by returning |
@CortneyOfstad Huh... This is 4 days overdue. Who can take care of this? |
@CortneyOfstad this issue was created 2 weeks ago. Are we close to a solution? Let's make sure we're treating this as a top priority. Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks! |
@CortneyOfstad Still overdue 6 days?! Let's take care of this! |
@CortneyOfstad Now this issue is 8 days overdue. Are you sure this should be a Daily? Feel free to change it! |
@TMisiukiewicz sorry for the delay here! For this comment, I would be leery to create a PR without the workflow, so leaning towards closing this. However, if you feel strongly that the PR should still be created, let me know and we can work it out with the team. Thanks! |
@CortneyOfstad Whoops! This issue is 2 days overdue. Let's get this updated quick! |
Hey @CortneyOfstad 👋 I took it over from @TMisiukiewicz and I also can't reproduce this, however I think we should still go about creating a PR fixing this. We can opt for a simpler solution, which is to use the optional chaining, see below: diff --git a/src/libs/Navigation/setupCustomAndroidBackHandler/index.android.ts b/src/libs/Navigation/setupCustomAndroidBackHandler/index.android.ts
index 10aa8b99a4..107dae2bb7 100644
--- a/src/libs/Navigation/setupCustomAndroidBackHandler/index.android.ts
+++ b/src/libs/Navigation/setupCustomAndroidBackHandler/index.android.ts
@@ -13,8 +13,7 @@ type SearchPageProps = StackScreenProps<BottomTabNavigatorParamList, typeof SCRE
function setupCustomAndroidBackHandler() {
const onBackPress = () => {
const rootState = navigationRef.getRootState();
-
- const bottomTabRoute = rootState.routes.find((route) => route.name === NAVIGATORS.BOTTOM_TAB_NAVIGATOR);
+ const bottomTabRoute = rootState?.routes?.find((route) => route.name === NAVIGATORS.BOTTOM_TAB_NAVIGATOR);
const bottomTabRoutes = bottomTabRoute?.state?.routes;
const focusedRoute = findFocusedRoute(rootState);
@@ -23,7 +22,7 @@ function setupCustomAndroidBackHandler() {
return false;
}
- const isLastScreenOnStack = bottomTabRoutes.length === 1 && rootState.routes.length === 1;
+ const isLastScreenOnStack = bottomTabRoutes.length === 1 && rootState?.routes?.length === 1;
if (NativeModules.HybridAppModule && isLastScreenOnStack) {
NativeModules.HybridAppModule.exitApp();
@@ -35,7 +34,7 @@ function setupCustomAndroidBackHandler() {
navigationRef.dispatch({...StackActions.pop(), target: bottomTabRoute?.state?.key});
navigationRef.dispatch({...StackActions.pop()});
- const centralPaneRouteAfterPop = getTopmostCentralPaneRoute({routes: [rootState.routes.at(-2)]} as State<RootStackParamList>);
+ const centralPaneRouteAfterPop = getTopmostCentralPaneRoute({routes: [rootState?.routes?.at(-2)]} as State<RootStackParamList>);
const bottomTabRouteAfterPop = bottomTabRoutes.at(-2);
// It's possible that central pane search is desynchronized with the bottom tab search.
@@ -57,7 +56,7 @@ function setupCustomAndroidBackHandler() {
// It's possible that central pane search is desynchronized with the bottom tab search.
// e.g. opening a tab different than search will wipe out central pane screens.
// In that case we have to push the proper one.
- if (bottomTabRoutes && bottomTabRoutes?.length >= 2 && bottomTabRoutes[bottomTabRoutes.length - 2].name === SCREENS.SEARCH.BOTTOM_TAB && rootState.routes.length === 1) {
+ if (bottomTabRoutes && bottomTabRoutes?.length >= 2 && bottomTabRoutes[bottomTabRoutes.length - 2].name === SCREENS.SEARCH.BOTTOM_TAB && rootState?.routes?.length === 1) {
const {policyID, ...restParams} = bottomTabRoutes[bottomTabRoutes.length - 2].params as SearchPageProps['route']['params'];
navigationRef.dispatch({...StackActions.push(SCREENS.SEARCH.CENTRAL_PANE, {...restParams, policyIDs: policyID})});
navigationRef.dispatch({...StackActions.pop(), target: bottomTabRoute?.state?.key});
This won't introduce any regressions and is more of a safety check. Ideally, when accessing nested optional properties, we use optional chaining, which was missing and causing this issue. As for the testing, I manually set |
That sounds great @hurali97! Thank you! |
Triggered auto assignment to @blimpich, see https://stackoverflow.com/c/expensify/questions/7972 for more details. |
@blimpich Can you confirm if this was deployed to production? I can't make out that. I can see it's deployed to staging 2 weeks back. If it is deployed then this would be ready for payout. |
Yes looks like it was deployed to production 👍 |
Sorry for the delay, automation must have messed up with the deploy notification |
Ah, part of this is probably because there was never |
thanks for taking a look @blimpich. @CortneyOfstad would be great if yo can share the payout summary. |
Sorry for the delay here! |
Payment Summary@mananjadhav — to be paid $250 via NewDot |
$250 approved for @mananjadhav |
Coming from this GH — #45054 (comment)
Reported by @TMisiukiewicz
Issue Owner
Current Issue Owner: @CortneyOfstadThe text was updated successfully, but these errors were encountered: