IndexedDBProvider upgradeCallback upon VersionError - #78
Merged
Eliran Eretz-Kedosha (eliranek1) merged 5 commits intoDec 2, 2025
Merged
Conversation
added 3 commits
July 15, 2025 13:27
Eliran Eretz-Kedosha (eliranek1)
previously approved these changes
Nov 20, 2025
Contributor
|
Reminder to bump the version |
Eliran Eretz-Kedosha (eliranek1)
previously approved these changes
Dec 2, 2025
Amit Shankar (amitshankar97)
approved these changes
Dec 2, 2025
Eliran Eretz-Kedosha (eliranek1)
approved these changes
Dec 2, 2025
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.
Hoist
upgradeCallbackinvocation onVersionErrorbefore wiping database contentThis change ensures that
upgradeCallbackis invoked when an IndexedDBVersionErroroccurs before any database wipe takes place. Today, whenwipeIfExists === false, theupgradeCallbackis never fired because the provider returns early while attempting to re-open the database (see early-return logic here: https://github.com/microsoft/ObjectStoreProvider/blob/78e1885d1e30e006a7d2252ce36f09e1cb772dd8/src/IndexedDbProvider.ts#L569C11-L577C12).Per MDN,
VersionErroris raised specifically during schema version downgrades—i.e., when opening a database with versionX - 1while it is currently initialized at versionX: https://developer.mozilla.org/en-US/docs/Web/API/IDBRequest/error#versionerror.By hoisting the
upgradeCallbackcall to occur immediately onVersionError, we guarantee that clients receive a reliable upgrade path even in downgrade scenarios. This allows clients to safely perform dependent cleanup operations (e.g., removing or migrating other dependent stores) before any potential database wipe occurs.