Ensure OnyxDB store is created & recover from corrupted database#684
Merged
Conversation
16 tasks
Contributor
|
Hold for my review |
fabioh8010
reviewed
Oct 2, 2025
| } | ||
|
|
||
| logInfo(`Store ${storeName} does not exist in database ${dbName}.`); | ||
| const nextVersion = db.version + 1; |
Contributor
There was a problem hiding this comment.
Why do we need to do this?
Contributor
Author
There was a problem hiding this comment.
IndexedDB only allows creating object stores during a version upgrade. If the store is missing (e.g., first run, cleared storage, or a previous version didn’t create it)
fabioh8010
approved these changes
Oct 2, 2025
Contributor
Author
|
All yours @mountiny |
mountiny
approved these changes
Oct 3, 2025
mountiny
left a comment
Contributor
There was a problem hiding this comment.
Thanks! Will move this one ahead
Contributor
|
@blazejkustra Lets make sure to get a checklist and testing on the App PR |
staszekscp
approved these changes
Oct 3, 2025
Contributor
52 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes: Expensify/App#69862
Context
The LeanConvert script loads as an HTML <script> and accesses OnyxDB’s IndexedDB store.
The bug occurred because it attempted to open OnyxDB when it didn’t exist. In doing so, it created the database without the required store, which corrupted our storage and froze the app.
More details in the issue. This was already fixed by the Convert team.
However, some clients may still have corrupted databases on their machines. To address this, when opening the database in Onyx, we now check if the store exists, and if not, create it. This ensures the database is no longer corrupted. The solution adds almost no overhead and reduces the chance of similar errors in the future.
Test steps
npm run buildin the Onyx repo and copy the code to the app.