Skip to content

Conversation

@jell0wed
Copy link
Collaborator

Hoist upgradeCallback invocation on VersionError before wiping database content

This change ensures that upgradeCallback is invoked when an IndexedDB VersionError occurs before any database wipe takes place. Today, when wipeIfExists === false, the upgradeCallback is 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, VersionError is raised specifically during schema version downgrades—i.e., when opening a database with version X - 1 while it is currently initialized at version X: https://developer.mozilla.org/en-US/docs/Web/API/IDBRequest/error#versionerror.

By hoisting the upgradeCallback call to occur immediately on VersionError, 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.

@jell0wed jell0wed self-assigned this Nov 20, 2025
eliranek1
eliranek1 previously approved these changes Nov 20, 2025
@eliranek1
Copy link
Contributor

Reminder to bump the version

eliranek1
eliranek1 previously approved these changes Dec 2, 2025
@eliranek1 eliranek1 merged commit 2e527ab into master Dec 2, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants