Skip to content
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

LF-3946 Show a fallback screen instead of white screen #3110

Merged

Conversation

kathyavini
Copy link
Collaborator

@kathyavini kathyavini commented Feb 5, 2024

Description

  • Installs the react-error-boundary package
  • Wraps the App + routes with the Error Boundary
  • Adds a fallback container which handles the reload + logout behaviour, including sending a tagged error to Sentry (tag is fallback_user_action; see example event here)
  • Adds the pure component + Storybook
  • Begins adding the new design system colours to src/assets/colors.scss

Note about the Failed to import dynamic module error:

Sadly I think the "TypeError: Failed to fetch dynamically imported module" error will not trigger the error boundary. I thought this would be considered an error in the <Routes /> component, but you can see looking at this Sentry error that it is instead a system exception. If you scroll to the bottom and expand the Event Grouping Information, the By In-App section (which contains the Component Stack for an error within the React component tree), is empty.

Jira link: https://lite-farm.atlassian.net/browse/LF-3946

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • Passes test case
  • UI components visually reviewed on desktop view
  • UI components visually reviewed on mobile view
  • Other (please explain)

I triggered what would normally be a whitescreen type error crash in two ways:

  • clear the litefarm_lang local storage value and click the LF logo (inspired by our recent bug bash!)
  • from transaction list, create an expense > view details > edit + save > view details > delete > back button until crash

I also tried to recreate the Failed to fetch dynamically imported module error, and as mentioned above, could not trigger the boundary that way. If you can think of any other kinds of known TypeError to test on, that would be great 🙏

Checklist:

  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • The precommit and linting ran successfully
  • I have added or updated language tags for text that's part of the UI
  • I have added "MISSING" for all new language tags to languages I don't speak
  • I have added the GNU General Public License to all new files

@kathyavini kathyavini added the enhancement New feature or request label Feb 5, 2024
@kathyavini kathyavini self-assigned this Feb 5, 2024
@kathyavini kathyavini requested review from a team as code owners February 5, 2024 21:54
@kathyavini kathyavini requested review from antsgar and SayakaOno and removed request for a team February 5, 2024 21:54
Copy link
Collaborator

@SayakaOno SayakaOno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

I made a TypeError: Cannot read properties of undefined (reading 'value') happen by adding console.log(undefined.value); and saw the fall back view :)

SayakaOno
SayakaOno previously approved these changes Feb 6, 2024
@antsgar
Copy link
Collaborator

antsgar commented Feb 7, 2024

@loicsans tagging you in this one for French translations

Copy link
Collaborator

@antsgar antsgar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a minor comment but this looks great! Love the new screens 🙂 and the use of Typescript!

}: PureReactErrorFallbackProps) => {
const { t } = useTranslation();

const isDesktop = useIsAboveBreakpoint('(min-width: 600px)');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lately we've been using MUI's breakpoints and their hook, in this case like this

const isDesktop = useMediaQuery(theme.breakpoints.down('sm'));

That way we always use the same breakpoints instead of typing in the number in the components. I think there's only one remaining component using useIsAboveBreakpoint which could be refactored as well and then we could remove the custom hook

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues with this component, but for refactoring the last component that uses useIsAboveBreakpoint... the breakpoint is 856px. Is it safe to round up to 900px (MUI breakpoint md)? @SayakaOno it is your component so I want to defer to you! This is the floating button on finances.

I think it looks okay at 900 but I want to make sure I'm not missing something 🙂

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

900px looks fine to me too. It looks like it was originally 768px, and I thought I just had followed Loïc's design, but I couldn't find any breakpoints in the mockups... also, it looks like Anto updated it to 856px here.
Setting a higher breakpoint seems safe...

}

.title {
color: #16423d; /* Figma's teal 900 on this page is not is not the app's teal 900 -- this should be checked */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The app's var is close enough that we could probably use that one?

Copy link
Collaborator Author

@kathyavini kathyavini Feb 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Discussed today in tech daily but just noting here for GitHub too)...

This colour is part of the new design system; Loïc provided this really helpful Figma link. Since we're going to move towards using CSS variables according to this convention, we'll eventually go the other way and migrate the old teal over when ready.

@antsgar antsgar self-requested a review February 8, 2024 11:46
@antsgar antsgar added this pull request to the merge queue Feb 8, 2024
Merged via the queue into integration with commit 532804d Feb 8, 2024
5 checks passed
@antsgar antsgar deleted the LF-3946-show-a-fallback-screen-instead-of-white-screen branch February 8, 2024 11:54
SayakaOno pushed a commit that referenced this pull request Jun 24, 2024
…een-instead-of-white-screen

LF-3946 Show a fallback screen instead of white screen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants