Skip to content

[$250] Login - Web - Onyx console error when opening the login site #60531

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

Open
1 of 8 tasks
jponikarchuk opened this issue Apr 19, 2025 · 22 comments
Open
1 of 8 tasks

[$250] Login - Web - Onyx console error when opening the login site #60531

jponikarchuk opened this issue Apr 19, 2025 · 22 comments
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review Weekly KSv2

Comments

@jponikarchuk
Copy link

jponikarchuk commented Apr 19, 2025

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number: 9.1.30-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: N/A
If this was caught during regression testing, add the test name, ID and link from TestRail: https://expensify.testrail.io/index.php?/tests/view/5957614
Email or phone of affected tester (no customers): N/A
Issue reported by: Applause Internal Team
Device used: Windows 10 / Chrome
App Component: Other

Action Performed:

  1. Open Chrome incognito and press F12 to open the console
  2. Navigate to https://staging.new.expensify.com/

Expected Result:

There shouldn't be any console errors.

Actual Result:

Onyx console error when opening the login site.

Workaround:

Unknown

Platforms:

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

1.mp4

2.txt

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021915877434962707714
  • Upwork Job ID: 1915877434962707714
  • Last Price Increase: 2025-04-25
@jponikarchuk jponikarchuk added Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 labels Apr 19, 2025
Copy link

melvin-bot bot commented Apr 19, 2025

Triggered auto assignment to @sakluger (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.

@nyomanjyotisa
Copy link
Contributor

nyomanjyotisa commented Apr 19, 2025

Proposal

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

Login - Web - Onyx console error when opening the login site

What is the root cause of that problem?

We set canBeMissing to false on some of the useOnyx on Expensify.tsx

App/src/Expensify.tsx

Lines 97 to 107 in 7e5a333

const [account] = useOnyx(ONYXKEYS.ACCOUNT, {canBeMissing: true});
const [session] = useOnyx(ONYXKEYS.SESSION, {canBeMissing: false});
const [lastRoute] = useOnyx(ONYXKEYS.LAST_ROUTE, {canBeMissing: true});
const [userMetadata] = useOnyx(ONYXKEYS.USER_METADATA, {canBeMissing: true});
const [isCheckingPublicRoom] = useOnyx(ONYXKEYS.IS_CHECKING_PUBLIC_ROOM, {initWithStoredValues: false, canBeMissing: false});
const [updateAvailable] = useOnyx(ONYXKEYS.UPDATE_AVAILABLE, {initWithStoredValues: false, canBeMissing: false});
const [updateRequired] = useOnyx(ONYXKEYS.UPDATE_REQUIRED, {initWithStoredValues: false, canBeMissing: false});
const [isSidebarLoaded] = useOnyx(ONYXKEYS.IS_SIDEBAR_LOADED, {canBeMissing: false});
const [screenShareRequest] = useOnyx(ONYXKEYS.SCREEN_SHARE_REQUEST, {canBeMissing: true});
const [focusModeNotification] = useOnyx(ONYXKEYS.FOCUS_MODE_NOTIFICATION, {initWithStoredValues: false, canBeMissing: false});
const [lastVisitedPath] = useOnyx(ONYXKEYS.LAST_VISITED_PATH, {canBeMissing: false});

On first load on incognito all will be empty

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

set canBeMissing to true on all useOnyx on Expensify.tsx

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

N/A

What alternative solutions did you explore? (Optional)

N/A

@mohit6789
Copy link
Contributor

mohit6789 commented Apr 19, 2025

🚨 Edited by proposal-police: This proposal was edited at 2025-04-19 13:58:04 UTC.

Proposal

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

Login - Web - Onyx console error when opening the login site

What is the root cause of that problem?

When we first time open the page in incognito mode lastVisitedPath is not exist and we pass canBeMissing: false here. So lastVisitedPath is must to present inside the Onyx. But for the first time lastVisitedPath is not present due to this we are getting error for lastVisitedPath.

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

To fix this issue we need to set canBeMissing: true only for lastVisitedPath key like below. We don't need to change in other keys because we already set default values for other keys when Onyx init from here. But here LAST_VISITED_PATH is undefined so we need to set canBeMissing: true.

Solution 1

const [lastVisitedPath] = useOnyx(ONYXKEYS.LAST_VISITED_PATH, {canBeMissing: true});

Or

Solution 2

We need to return some initial data from here

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

NA

What alternative solutions did you explore? (Optional)

To fix this issue we need to set initWithStoredValues: false for lastVisitedPath key.

const [lastVisitedPath] = useOnyx(ONYXKEYS.LAST_VISITED_PATH, {initWithStoredValues: false, canBeMissing: true});

@ChavdaSachin
Copy link
Contributor

ChavdaSachin commented Apr 20, 2025

Proposal

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

Login - Web - Onyx console error when opening the login site

What is the root cause of that problem?

RCA - When a user opens the the app for the first time from incognito tab - the value of lastVisitedPath is missing from Onyx, and hence a console error is triggered, since it's expected to be present during app initialization.

const [lastVisitedPath] = useOnyx(ONYXKEYS.LAST_VISITED_PATH, {canBeMissing: false});

  • But Why is is missing even though lastVisitedPath values are initialized here ?
    => Because we only initialize lastVisitedPath value for native devices and not for web devices since we don't want to reset the value of lastVisitedPath key, so that user always would be redirected to lastVisitedPath between app revisits.
    And hence initializing lastVisitedPath for web may cause some side effects.

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

  • Since this problem may only happen on login page which would only be loaded when user is not logged in we should pass canBeMissing = true only on login page(ie. when no user is logged in).
  • To do so we could make use of isAnonymousUser function which returns true when user is not logged in.
    function isAnonymousUser(sessionParam?: OnyxEntry<Session>): boolean {
  • And conditionally pass the value of canBeMissing argument to handle this sole exception while keeping the goodness of canBeMissing = false for rest of the app other than login page.
    const [lastVisitedPath] = useOnyx(ONYXKEYS.LAST_VISITED_PATH, {canBeMissing: isAnonymousUser() || false});

const [lastVisitedPath] = useOnyx(ONYXKEYS.LAST_VISITED_PATH, {canBeMissing: false});

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

NA

What alternative solutions did you explore? (Optional)

Optionally we could make use of Navigation module to check for current path and conditionally pass canBeMissing = true in case the current page is login page.
To implement this, we might need to move this code block here

const [focusModeNotification] = useOnyx(ONYXKEYS.FOCUS_MODE_NOTIFICATION, {initWithStoredValues: false, canBeMissing: false});

so that navigation path is initialized before retrieving the value of lastVisitedPath from Onyx DB.

Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

@sakluger
Copy link
Contributor

Question for people who posted proposals: Does this console error negatively affect end users in any way? If so, what problem is caused for end users?

@ChavdaSachin
Copy link
Contributor

No this console error does not effect end users any how.
This console errors are only a means to catch bugs in advanced.

When canBeMissing is passed value - false, that indicates this particular object should be present in the onyx value store or else it would trigger console error in staging and production and would provide an alert in dev env.

So philosophy for the key is - pass false for the objects which are absolutely necessary to render the page and could potentially crash the page/app in case values are missing in onyx store, so to catch any potential bug prior to a crash due to missing values.

Find more context here - #58499

cc. @sakluger

@melvin-bot melvin-bot bot added the Overdue label Apr 24, 2025
@sakluger
Copy link
Contributor

@iwiznia tagging you because you were assigned to the GH issue linked in the previous comment. Do you think we should fix this console error, or can we just close the issue given that it doesn't affect end users?

@melvin-bot melvin-bot bot removed the Overdue label Apr 24, 2025
@iwiznia
Copy link
Contributor

iwiznia commented Apr 24, 2025

Yes we should fix it, having no console errors is part of the check lists.
Also canBeMissing should not be alerting/logging (I added that to the check list here #60848)

We discussed a couple of canBeMissing bugs here https://expensify.slack.com/archives/C03TQ48KC/p1745496127741719 I assume this is one of those, but in any case it should be assigned to whoever introduced the log line and counted as a regression.

@sakluger sakluger added the External Added to denote the issue can be worked on by a contributor label Apr 25, 2025
@melvin-bot melvin-bot bot changed the title Login - Web - Onyx console error when opening the login site [$250] Login - Web - Onyx console error when opening the login site Apr 25, 2025
Copy link

melvin-bot bot commented Apr 25, 2025

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

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Apr 25, 2025
Copy link

melvin-bot bot commented Apr 25, 2025

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

@sakluger
Copy link
Contributor

Got it, thanks! I'll add the external label. @shubham1206agra could you help determine where the regression came from so that we can assign the correct person to fix this?

@sakluger sakluger removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Apr 25, 2025
@sakluger sakluger moved this to Bugs and Follow Up Issues in #expensify-bugs Apr 25, 2025
@shubham1206agra
Copy link
Contributor

shubham1206agra commented Apr 26, 2025

@sakluger The offending PR was #59191, but it is out of the regression period.

@fabioh8010 Can you take this issue up?

@sakluger
Copy link
Contributor

@fabioh8010 I assigned you to the issue. Could you please take a look and see if this is something you should work on?

@melvin-bot melvin-bot bot removed the Overdue label Apr 28, 2025
@VickyStash
Copy link
Contributor

@fabioh8010 is OOO this week, but I'll ask if someone from the team wants to take it over!

@martasudol
Copy link
Contributor

Hi, I'm Marta from Callstack. Please assign me to this issue, I can take it over ✌

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Apr 29, 2025
@eh2077
Copy link
Contributor

eh2077 commented Apr 30, 2025

Hi @martasudol, would you like to fix this issue #60991 (comment) together in your PR? Thanks

@martasudol
Copy link
Contributor

Hi @martasudol, would you like to fix this issue #60991 (comment) together in your PR? Thanks

Sure! Let me fix it in my PR 🖖

@martasudol
Copy link
Contributor

martasudol commented Apr 30, 2025

@iwiznia, since these errors appear throughout the entire app, changing individual canBeMissing flags to true feels more like a workaround than a proper fix.
My PR resolves the issues on the login and onboarding screens, but the same errors still occur elsewhere in the app.

Could you provide more context on why this value is needed in the first place?
If there's a good reason to keep it, maybe a better solution would be to set the default value of this prop to true in Onyx?

Curious to hear your thoughts on this! 🖖

CC @fabioh8010

@sakluger sakluger removed their assignment May 2, 2025
@sakluger sakluger added Bug Something is broken. Auto assigns a BugZero manager. and removed Bug Something is broken. Auto assigns a BugZero manager. labels May 2, 2025
Copy link

melvin-bot bot commented May 2, 2025

Triggered auto assignment to @johncschuster (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.

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels May 2, 2025
@sakluger sakluger self-assigned this May 2, 2025
@sakluger
Copy link
Contributor

sakluger commented May 2, 2025

I will be OOO from May 5 - 16, so I have added another BZ member to watch over the issue while I'm out.

@sakluger sakluger added Weekly KSv2 and removed Daily KSv2 labels May 2, 2025
Copy link

melvin-bot bot commented May 7, 2025

Triggered auto assignment to @iwiznia, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

@iwiznia
Copy link
Contributor

iwiznia commented May 20, 2025

since these errors appear throughout the entire app, changing individual canBeMissing flags to true feels more like a workaround than a proper fix.

The thing is that no new ones should be appearing, since they create a console error and we should not merge PRs with console errors (it's part of the checklist). So if new ones appear, we should assign them to whoever added that canBeMissing param so they can inspect it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review Weekly KSv2
Projects
Status: Bugs and Follow Up Issues
Development

No branches or pull requests