-
Notifications
You must be signed in to change notification settings - Fork 82
Update error handling in Onyx to prevent unnecessary data eviction #694
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
base: main
Are you sure you want to change the base?
Update error handling in Onyx to prevent unnecessary data eviction #694
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me, i just have a few minor comments 🙌🏼
lib/OnyxUtils.ts
Outdated
| * - Other errors: retries the operation | ||
| */ | ||
| function evictStorageAndRetry<TMethod extends typeof Onyx.set | typeof Onyx.multiSet | typeof Onyx.mergeCollection | typeof Onyx.setCollection>( | ||
| function retryOperation<TMethod extends typeof Onyx.set | typeof Onyx.multiSet | typeof Onyx.mergeCollection | typeof Onyx.setCollection>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NAB: Do you think it would be feasible to add a type backing TMethod that requires an onyx method to have an optional retryAttempt parameter on the last position? 👀
evictStorageAndRetry to not evict the data if error isn't storage relatedThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor things!
@VickyStash is possible to add some unit tests to cover these retry mechanisms?
Sure, it's planned! I've mentioned it here. |
|
While writing the tests, I've found some flaws in the eviction mechanism. We get react-native-onyx/lib/OnyxCache.ts Lines 419 to 429 in 6a24680
In the So if we react-native-onyx/lib/OnyxUtils.ts Line 899 in 6a24680
We notify subscribers about that => the key is added to the recentlyAccessedKeys.
It means:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, i have minor requests but these are not blockers. Thanks for your work @VickyStash 🙌🏼
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the changes! LGTM!
# Conflicts: # lib/Onyx.ts
|
@abzokhattab Can you please take another look? |
|
@VickyStash sure! taking alook now |
|
Added a small comment here, but overall the changes look good to me. Keep up the great work @VickyStash 🎉 |
|
I see the reassure check is failing, but it looks like it failed with the same error on other PRs as well today, so I think it's not related to this PR:
@TMisiukiewicz I see this comment from you, but I guess it shouldn't fail anymore, right? |
|
@VickyStash yeah I think it should not fail, I can see that |
But I see the same test was failing in your PR as well, and was merged into main with the failing check. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed in Slack here that the reassure tests seem to be flaky so we should not hold on this https://expensify.slack.com/archives/C05LX9D6E07/p1762287203445669?thread_ts=1762215968.042109&cid=C05LX9D6E07
One question still though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I think there are only one NAB left and we dont need to hold on that
# Conflicts: # lib/Onyx.ts # lib/OnyxUtils.ts # tests/unit/onyxUtilsTest.ts
Details
This PR updates error handling by:
Related Issues
$ Expensify/App#73779
Automated Tests
Added to
tests/unit/onyxUtilsTest.tsManual Tests
Before

After
Author Checklist
### Related Issuessection aboveTestssectiontoggleReportand notonIconClick)myBool && <MyComponent />.STYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)/** comment above it */thisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)Avataris modified, I verified thatAvataris working as expected in all cases)mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop