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

Add canBeMissing configuration option to useOnyx #58499

Open
iwiznia opened this issue Mar 14, 2025 · 3 comments
Open

Add canBeMissing configuration option to useOnyx #58499

iwiznia opened this issue Mar 14, 2025 · 3 comments

Comments

@iwiznia
Copy link
Contributor

iwiznia commented Mar 14, 2025

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.
@fabioh8010
Copy link
Contributor

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

@fabioh8010
Copy link
Contributor

As discussed in Slack I will start looking mid next week

@iwiznia
Copy link
Contributor Author

iwiznia commented Mar 14, 2025

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?

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

No branches or pull requests

2 participants