Skip to content

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

@iwiznia

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.

Metadata

Metadata

Labels

BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions