Skip to content

[Due for payment 2025-04-25] [CRITICAL] Add canBeMissing configuration option to useOnyx #58499

Closed

Description

@iwiznia

Context https://expensify.slack.com/archives/C03TQ48KC/p1741208342513379

Problem:

The backend doesn't know all the data the frontend needs, the frontend doesn't know if the we actually loaded from the backend all the data it is expecting/using. This leads to hard to debug/reproduce bugs when frontend tries to access a piece of data it thinks should exist but wasn't really loaded.

Solution:

Add a way so that we can indicate in the useOnyx calls if the data is ok to be missing or if we were expecting it to be there for sure:

  • We will add a new param to useOnyx called canBeMissing
  • We will add an ESLint rule so that all calls to useOnyx need to pass it (this is to allow us to add this param little by little instead of having to audit all useOnyx calls at once)
  • When the param is false and the useOnyx call returns no data, we will log an alert in production (which will create issues for us to investigate). In dev we will instead throw, to try to catch the problem before it hits production, when you are working on dev (we need to double check this, if it is throwing everywhere then let's just log instead, as we don't want to break everything)
  • Once all places that call useOnyx are passing the param, we will remove the ESLint rule and make the param in useOnyx mandatory
  • To handle the case where data is being loaded from the DB/cache, the alert won't be logged in the case status is loading and when status changes to loaded then it would log if data is null and canBeMissing was true.

Activity

  1. fabioh8010 commented on Mar 14, 2025

    @fabioh8010
    Contributor

    Hey, I'm Fábio - expert agency contributor - and I would like to work on this issue!

  2. fabioh8010 commented on Mar 14, 2025

    @fabioh8010
    Contributor

    As discussed in Slack I will start looking mid next week

  3. iwiznia commented on Mar 14, 2025

    @iwiznia
    ContributorAuthor

    We will add an ESLint rule so that all calls to useOnyx need to pass it (this is to allow us to add this param little by little instead of having to audit all useOnyx calls at once)

    Thinking about this, I am not sure it will work since IIRC the ESLint rules in App run for all files and not only modified files?

  4. mallenexpensify commented on Mar 18, 2025

    @mallenexpensify
    Contributor

    Should this be on #quality as MEDIUM cuz of the below?

    • MEDIUM - Debugging Tools to help make fixing existing bugs easier and getting fixes to customers faster and Architectural Improvements to the underlying framework and design of the app to improve performance, scalability, and maintainability
  5. iwiznia commented on Mar 18, 2025

    @iwiznia
    ContributorAuthor

    This is holding other issues marked as critical, so I assume should be critical too.
    Anyway, @fabioh8010 said he was going to work on this mid this week, so hopefully we have a PR soon.

  6. changed the title [-]Add canBeMissing configuration option to useOnyx[/-] [+][CRITICAL] Add canBeMissing configuration option to useOnyx[/+] on Mar 19, 2025
  7. fabioh8010 commented on Mar 19, 2025

    @fabioh8010
    Contributor

    We will add an ESLint rule so that all calls to useOnyx need to pass it (this is to allow us to add this param little by little instead of having to audit all useOnyx calls at once)

    Thinking about this, I am not sure it will work since IIRC the ESLint rules in App run for all files and not only modified files?

    @iwiznia We can use .eslintrc.changed.js to achieve this. It will only execute for the changed files of a PR.


    When the param is false and the useOnyx call returns no data, we will log an alert in production (which will create issues for us to investigate). In dev we will instead throw, to try to catch the problem before it hits production, when you are working on dev (we need to double check this, if it is throwing everywhere then let's just log instead, as we don't want to break everything)

    I think we shouldn't throw errors on dev, I believe it could lead to widespread crashes if for example we have an useOnyx with canBeMissing set to false that is inside a component or hook that is used throughout the codebase.

  8. fabioh8010 commented on Mar 19, 2025

    @fabioh8010
    Contributor

    Updates:

    • Created first implementation of the feature and some unit tests. WIP Draft PR here.
    • Will also proceed to start implementation of the ESLint rule, so I can test both together in advance.
    • @iwiznia I will leave a question for you in the PR about a use case that I'm not sure.
  9. 47 remaining items

  10. mallenexpensify commented on May 1, 2025

    @mallenexpensify
    Contributor

    @parasharrajat you'll be due $250 for the review of #61056 , correct?
    Are you due $250 (had $350 here, was a typo) for #59191 too?

    Anyone else due 💰 here?

  11. parasharrajat commented on May 1, 2025

    @parasharrajat
    Member

    @mallenexpensify This issue was critical, so the pay would be 500 for this issue.
    #61056 will be handled separately as a new change done later on #61076

  12. mallenexpensify commented on May 2, 2025

    @mallenexpensify
    Contributor

    @parasharrajat , this was updated to CRITICAL on March 18th, I think that was before I started updating CRITICAL issues to $500. (also.. it's not a set-in-stone rule that all CRITICAL will be $500, I do think that most/many should be, if they're External, to help get 👀 though). I want to avoid having to retroactively review many issues to potentially increase the amount.

    Do you feel the amount of work, complexity or scope increased on the issue or PR? That could be reason for a potential price increase/

  13. parasharrajat commented on May 2, 2025

    @parasharrajat
    Member

    I am fine with 250 as well for this issue instead of 500.

  14. mallenexpensify commented on May 2, 2025

    @mallenexpensify
    Contributor

    Contributor+: @parasharrajat due $250 via NewDot

    Unsure if can close so I'll leave open til it goes overdue again

  15. mallenexpensify commented on May 5, 2025

    @mallenexpensify
    Contributor

    Closing

  16. ChavdaSachin commented on May 8, 2025

    @ChavdaSachin
    Contributor

    Also @ChavdaSachin you'll be invited to #expensify-open-source pretty soon. I need to create an automated process for new invites and I haven't been able to prioritize it quite yet.

    @mallenexpensify do you have any update on this?
    I could help you voluntarily to automate the task if it is possible.

    I am really stuck on an issue for about 15 days and it is really difficult for externals to work without being on slack.

    Thank you.

  17. mallenexpensify commented on May 10, 2025

    @mallenexpensify
    Contributor

    @ChavdaSachin , the co-worker I'm working with on the automation returns to work on Monday, so hopefully it won't be too much longer

    I am really stuck on an issue for about 15 days

    Feel free to tag me in the issue to see if I can help.

  18. parasharrajat commented on May 23, 2025

    @parasharrajat
    Member

    Payment requested as per #58499 (comment)

  19. JmillsExpensify commented on May 29, 2025

    @JmillsExpensify
    Contributor

    $250 approved for @parasharrajat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugDaily

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions