[Onyx Audit] prevent storage reads for RAM-only keys#740
[Onyx Audit] prevent storage reads for RAM-only keys#740JKobrynski wants to merge 4 commits intoExpensify:mainfrom
Conversation
fabioh8010
left a comment
There was a problem hiding this comment.
Early review – Could we also add some tests for RAM-only keys in useOnyxTest.ts too? We have for the deprecated initWithStoredValues but don't have any of RAM-only keys there.
…91-prevent-storage-reads-for-ram-only-keys
|
@JKobrynski @mountiny I can review and test this once it’s ready for review, since it’s linked to Expensify/App#80091. |
|
@Krishna2323 ready for review! |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b4f4b05f80
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const filteredKeys = keys.filter((key) => !isRamOnlyKey(key)); | ||
| cache.setAllKeys(filteredKeys); |
There was a problem hiding this comment.
Preserve RAM-only keys for storage cleanup
Do not filter RAM-only keys out of getAllKeys() before the clear flow runs, because Onyx.clear() derives keysToBeClearedFromStorage from OnyxUtils.getAllKeys() (lib/Onyx.ts, clear path) and already avoids re-writing RAM-only defaults. With this filter, any stale persisted value from a pre-migration version (key later marked RAM-only) is no longer discoverable by clear(), so logout/clear leaves that data on disk indefinitely instead of removing it.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Seems like its been already discussed here.
There was a problem hiding this comment.
Right! I also checked if this breaks any existing logic, and everything looked fine.
|
Will review in 15mins. |
|
@JKobrynski should we mention this behavioral change in the PR description or somewhere? Please also check this comment from the AI review, seems legit to me.
|
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppandroid_native.mp4Android: mWeb Chromeandroid_chrome.mp4iOS: HybridAppios_native.mp4iOS: mWeb Safariios_safari.mp4MacOS: Chrome / Safariweb_chrome.mp4 |
Krishna2323
left a comment
There was a problem hiding this comment.
LGTM and works well! 🚀
Left a minor comment/suggestion: #740 (comment)
mountiny
left a comment
There was a problem hiding this comment.
Nice thanks @Krishna2323 !
@JKobrynski Can you please address those comments?
|
@mountiny on it |
I'm not sure what you mean, this wasn't introduced in this PR right? |
|
@JKobrynski sorry for that, seems like I meant to add that comment elsewhere. |
|
No worries! Are we good to go here or would you like me to clarify something else? |
|
Nope. Everything else looks good to me. Thanks! |
|
@mountiny can we merge this? I can prepare a bump right away |
Details
This is a solution to the RAM-only migration. You can check the conversation in the issue starting with this comment where I suggested two potential solutions and solution 1 (the one that this PR implements) was accepted.
Related Issues
GH_LINK Expensify/App#80091
Automated Tests
Unit tests to the newly implemented logic were created.
Manual Tests
Simply test the base flows of E/App to make sure everything works correctly, especially the sign in.
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
web-compressed.mov
MacOS: Desktop