IndexedDBProvider upgradeCallback upon VersionError #78
+16
−14
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.