Expensify / App

Welcome to New Expensify: a complete re-imagination of financial collaboration, centered around chat. Help us build the next generation of Expensify by sharing feedback and contributing to the code.
https://new.expensify.com
MIT License
3.48k stars 2.83k forks source link

[$250] DEV: Investigate the console errors that show up after signing in #45619

Closed youssef-lr closed 1 month ago

youssef-lr commented 3 months ago

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: Reproducible in staging?: Reproducible in production?: If this was caught during regression testing, add the test name, ID and link from TestRail: Email or phone of affected tester (no customers): Logs: https://stackoverflow.com/c/expensify/questions/4856 Expensify/Expensify Issue URL: Issue reported by: Slack conversation:

Action Performed:

  1. Sign in to NewDot locally

Expected Result:

Ideally, no error should be shown in the console.

Actual Result:

Many console errors show up and they are distracting, it's hard to know which one of them is causing a UI issue.

As of now here are the errors I'm seeing:

Screenshot 2024-07-17 at 18 01 22 Screenshot 2024-07-17 at 18 01 29

Workaround:

Can the user still use Expensify without this being fixed? Have you informed them of the workaround?

Platforms:

Which of our officially supported platforms is this issue occurring on?

Screenshots/Videos

Add any screenshot/video evidence

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01b447136e274124b6
  • Upwork Job ID: 1813619813398356556
  • Last Price Increase: 2024-07-31
  • Automatic offers:
    • hoangzinh | Reviewer | 103403426
Issue OwnerCurrent Issue Owner: @hoangzinh
melvin-bot[bot] commented 3 months ago

Job added to Upwork: https://www.upwork.com/jobs/~01b447136e274124b6

melvin-bot[bot] commented 3 months ago

Triggered auto assignment to Contributor-plus team member for initial proposal review - @hoangzinh (External)

melvin-bot[bot] commented 3 months ago

Triggered auto assignment to @puneetlath (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

mosesbabu commented 3 months ago

Please re-state the problem that we are trying to solve in this issue. Investigate the console errors that show up after signing in

What is the root cause of that problem? 1.the View components may have plain text is directly inside them will check Wrap all text with Text components. 2.some libraries are using deprecated methods like findDOMNode will check and update them What changes do you think we should make in order to solve the problem?

  1. will check Wrap all text with Text components.
  2. will check libraries using depreciated methods such as findDOMNode and update them
hoangzinh commented 3 months ago

Hi @mosesbabu can you format your proposal same as PROPOSAL_TEMPLATE here? Besides that, the root cause needs to be more details and clearly point out which is causing the issue. Thank you.

mosesbabu commented 3 months ago

ok noted doing so right now. was asking if the issue is not yet assigned as well thank you

hoangzinh commented 3 months ago

yep, it is still open for proposals

mosesbabu commented 3 months ago

Proposal

i recreated the error locally there are more errors as well on the console apart from these can check them as well

Please re-state the problem that we are trying to solve in this issue.

Investigate the console errors that show up after signing in

What is the root cause of that problem?

The RCA was not how react handled the routes but this is fixed

Screenshot from 2024-07-18 21-57-29

What alternative solutions did you explore? (Optional)

there are so many other errors i can clear them all if hired Screenshot from 2024-07-20 04-19-26 Screenshot from 2024-07-20 04-19-47 Screenshot from 2024-07-20 04-20-08 Screenshot from 2024-07-20 04-20-27

hoangzinh commented 2 months ago

It looks better @mosesbabu, but next time, you don't need to post a new proposal, just update the existing one.

This error occurs when trying to access the routes property of an undefined object.

Can you elaborate more on it in your RCA? Which line of code caused this error? How can it happen? In RCA, we have to describe the root cause in detail as much as possible.

melvin-bot[bot] commented 2 months ago

@puneetlath, @hoangzinh Whoops! This issue is 2 days overdue. Let's get this updated quick!

hoangzinh commented 2 months ago

@mosesbabu is your proposal ready for the next review? If yes, please post a new comment according to step 7 of the guidelines https://github.com/Expensify/App/blob/main/contributingGuides/CONTRIBUTING.md#propose-a-solution-for-the-job

mosesbabu commented 2 months ago

Yes it's ready for review apologies this is my first time with expensify am I supposed to first fix the error or wait to be hired first

melvin-bot[bot] commented 2 months ago

πŸ“£ It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? πŸ’Έ

hoangzinh commented 2 months ago

No worry @mosesbabu.

caused by findDomNode being depreciated in StrictMode

Your RCA is still not clear to me. Can you point out exactly which line of codes in Expensify/App repo or libraries that cause this error? Thank you.

mosesbabu commented 2 months ago

@hoangzinh The findDOMNode being depreciated error arises from this specific library is react-native-gesture-handler library in react not anywhere in the code as app is running on strictMode shows that its depreciated to fix is by using refs in componetts raising the error example component is :src/components/Pressable/GenericPressable/BaseGenericPressable.tsx however a depreciated warning doesnt keep app from running

hoangzinh commented 2 months ago

to fix is by using refs in componetts raising the error example component is :src/components/Pressable/GenericPressable/BaseGenericPressable.tsx

Cool. Can you share more details on how you would fix it in the BaseGenericPressable component?

bernhardoj commented 2 months ago

Proposal

Please re-state the problem that we are trying to solve in this issue.

A few console error.

What is the root cause of that problem?

If we look at the video play() error stacktrace image, we can see that it's coming from the onboarding video. If you open /onboarding/welcome-video, then you will all the errors + other errors that doesn't show in the OP, except the routes error (the routes error only show when loggin in). Here is the explanation of each error:

  1. Warning: findDOMNode is deprecated in StrictMode This error comes from react-native-gesture-handler and needs to be fixed on the upstream repo.

  2. Warning: Using UNSAFE_componentWillReceiveProps in strict mode is not recommended and may indicate bugs in your code This error comes from react-native-animatable and needs to be fixed on the upstream repo.

  3. TypeError: Cannot read properties of undefined (reading 'routes') The getState() in resetHomeRouteParams is undefined. https://github.com/Expensify/App/blob/d8d7f7887ea28c70ba71a06be87fcacd2436e2bc/src/libs/actions/Session/index.ts#L678-L680

We previously have this kind of issue too in https://github.com/Expensify/App/pull/37194.

  1. Unexpected text node. This means there is a text rendered without a <Text> component. This erro comesfrom FeatureTrainingModal where we conditionally render a component based on a string value, but if it's empty, then '' is rendered. https://github.com/Expensify/App/blob/6fcca3c2c941fb85761ee88568a5b17e040b8140/src/components/FeatureTrainingModal.tsx#L218-L225

  2. validateDOMNesting(...):

The code above is to fix https://github.com/Expensify/App/issues/36906.

  1. play() failed because the user didn't interact with the document first. The onboardoing video is auto-played, but the browser doesn't allow that without the user interacting first, except if the video is muted (read more here.

We mute the volume here initially, but not immediately. https://github.com/Expensify/App/blob/6fcca3c2c941fb85761ee88568a5b17e040b8140/src/components/VideoPlayerContexts/VolumeContext.tsx#L11-L32

  1. The play() request was interrupted by a call to pause(). This is explained in https://developer.chrome.com/blog/play-request-was-interrupted. play() is async and if a pause is called before the play() is resolved, the error is thrown. In our case, the currentReportID is changed from an empty string to the topmost reportID that triggers resetVideoPlayerData() which calls stopVideo().

https://github.com/Expensify/App/blob/00d2c42b4a1d53696e4cb0808ba31fc10028ffcd/src/components/VideoPlayerContexts/PlaybackContext.tsx#L85-L90 https://github.com/Expensify/App/blob/00d2c42b4a1d53696e4cb0808ba31fc10028ffcd/src/components/VideoPlayerContexts/PlaybackContext.tsx#L75-L77

  1. The play() request was interrupted because the media was removed from the document Can't reproduce it anymore.

What changes do you think we should make in order to solve the problem?

  1. Add null safety when accessing the state

    const routes = navigationRef.current?.getState()?.routes;
  2. Use !! to check the text.

    {!!title && !!description && <.../>}
    ...
    {!!helpText && <.../>}
  3. Remove the accessibilityRole so it's rendered as a div https://github.com/Expensify/App/blob/6fcca3c2c941fb85761ee88568a5b17e040b8140/src/components/VideoPlayer/BaseVideoPlayer.tsx#L299-L300

  4. Immediately mute the video when mounted in BaseVideoPlayer

    useEffect(() => {
    videoPlayerRef.current?.setStatusAsync({volume: 0});
    }, []);
  5. Two ways to solve this. First, only stop the video if the video is playing.

    checkVideoPlaying((isPlaying) => {
    videoResumeTryNumberRef.current = 0;
    if (isPlaying) {
        stopVideo();
    }
    setCurrentlyPlayingURL(null);
    ... // rest
    });

Or, store the previous currentReportID

const prevCurrentReportID = usePrevious(currentReportID);

and don't call resetVideoPlayerData if the prevCurrentReportID is empty. This way, if the currentReportID is set for the first time, we won't call resetVideoPlayerData and it will only be called if the currentReportID is really changed (instead of being triggered from empty string to the topmost report ID).

if (!currentReportID || !prevCurrentReportID) {
    return;
}
resetVideoPlayerData();
puneetlath commented 2 months ago

Thoughts @hoangzinh?

melvin-bot[bot] commented 2 months ago

@puneetlath, @hoangzinh Huh... This is 4 days overdue. Who can take care of this?

hoangzinh commented 2 months ago

Hi @puneetlath, the first 2 warnings in RCA of @bernhardoj's proposal https://github.com/Expensify/App/issues/45619#issuecomment-2255682959 they're only in strict mode and need to be fixed in upstream repos (Warning: findDOMNode and Warning: Using UNSAFE_componentWillReceiveProps). Do you think we should fix it or can leave it there?

melvin-bot[bot] commented 2 months ago

πŸ“£ It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? πŸ’Έ

hoangzinh commented 2 months ago

@bernhardoj

  1. Immediately mute the video when mounted

I tried to apply your suggestion but it didn't work. Can you share exactly the component/where we should set mute for the player?

  1. The play() request was interrupted by a call to pause().

I couldn't reproduce this error. Are you still able to reproduce it?

melvin-bot[bot] commented 2 months ago

@puneetlath @hoangzinh this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!

bernhardoj commented 2 months ago

I tried to apply your suggestion but it didn't work. Can you share exactly the component/where we should set mute for the player?

You can put the code in BaseVideoPlayer. I have added this info to my proposal.

I couldn't reproduce this error. Are you still able to reproduce it?

After retesting, the app is lagging before the video shows and I can't reproduce it. But after muting the video immediately, the app runs smoother and I can reproduce the issue again.

hoangzinh commented 2 months ago

Oh, you're right. Let's wait for @puneetlath thoughts on https://github.com/Expensify/App/issues/45619#issuecomment-2260852821

puneetlath commented 2 months ago

Let's focus on fixing the ones that can be handled on our side for now in this issue.

hoangzinh commented 2 months ago

Thanks @puneetlath. @bernhardoj proposal looks good to me.

Link to proposal https://github.com/Expensify/App/issues/45619#issuecomment-2255682959

πŸŽ€πŸ‘€πŸŽ€ C+ reviewed

melvin-bot[bot] commented 2 months ago

Current assignee @puneetlath is eligible for the choreEngineerContributorManagement assigner, not assigning anyone new.

melvin-bot[bot] commented 2 months ago

πŸ“£ @hoangzinh πŸŽ‰ An offer has been automatically sent to your Upwork account for the Reviewer role πŸŽ‰ Thanks for contributing to the Expensify app!

Offer link Upwork job

bernhardoj commented 2 months ago

PR is ready

cc: @hoangzinh

melvin-bot[bot] commented 1 month ago

This issue has not been updated in over 15 days. @puneetlath, @hoangzinh, @bernhardoj eroding to Monthly issue.

P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!

puneetlath commented 1 month ago

I think we're good to pay this one out. @hoangzinh can you complete the checklist?

hoangzinh commented 1 month ago

Sure, I will complete the checklist today

hoangzinh commented 1 month ago

BugZero Checklist:

Console error 3rd: TypeError: Cannot read properties of undefined (reading 'routes') Console error 4th: Unexpected text node Console error 5th: validateDOMNesting(...): cannot appear as a descendant of Console error 6th: play() failed because the user didn't interact with the document first Console error 7th: The play() request was interrupted by a call to pause()

hoangzinh commented 1 month ago

I think we're good to pay this one out. @hoangzinh can you complete the checklist?

BZ checklist is complete , @puneetlath

puneetlath commented 1 month ago

Payment summary:

Thanks everyone!

bernhardoj commented 1 month ago

Requested in ND.

JmillsExpensify commented 1 month ago

$250 approved for @bernhardoj