fix(idxdb-store): reset IndexedDB on client version downgrade - #355
fix(idxdb-store): reset IndexedDB on client version downgrade#355kutluhaneth46 wants to merge 4 commits into
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
|
Thanks for picking this up. One thing on the condition.
A patch release should not change the store schema, so wiping there costs the user their accounts and notes for no reason. Someone pinning back one patch would hit it.
if (sameMajorMinor) {
await this.persistClientVersion(clientVersion);
return;
}Same fix for the downgrade I hit, one condition less, and the patch line keeps its data. Worth a test for |
sameMajorMinor alone preserves data for patch upgrades and pin-backs; major/minor crossings still reset. Adds 0.15.9 -> 0.15.8 regression coverage per review. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Thanks @Mustdzyl — good catch. Dropped the |
|
I pulled the actual packages to check the downgrade path, and I don't think this fires for the case in the test name.
await this.dexie.open(); // throws here
await this.ensureClientVersion(clientVersion); // never reachedThere is no VersionError branch, and the only The test passes because both opens go through the schema on this branch, which declares 1..2 either way. What differs is the stored version string, not the IndexedDB version, so the version-5 store that the RC creates is never reproduced. Would catching it around the open cover the real case? try {
await this.dexie.open();
} catch (err) {
if (err?.name === "VersionError") { await this.dexie.delete(); await this.dexie.open(); }
else throw err;
}The README line probably wants softening until that holds, since it promises the reset is automatic. |
…ersion RC clients can advance Dexie past what 0.15.x declares, so open() throws VersionError and never reaches the client-version reset. Catch that, delete, reopen; soften the README claim accordingly. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Thanks @Mustdzyl — you're right. With a real RC store at Dexie v5, Pushed a follow-up that:
|
|
One more direction, in case it belongs in the same PR. The VersionError catch covers the downgrade. The upgrade direction fails earlier and differently. On a clean origin I created a store with 0.15.9, then loaded 0.16.0-rc.7 on the same origin: That happens before any network call, so the client never starts. Dexie opens fine here because rc.7 declares a higher schema version and runs its own upgrade, so nothing throws VersionError and the new catch does not fire. What breaks is reading 0.15.9 era rows with the newer deserializer. With the same origin cleared first, rc.7 gets past that and fails at the RPC instead, which is the version mismatch you would expect against the current testnet: So someone upgrading when testnet moves to 0.16 lands on the storage error rather than a recoverable reset. Should the catch widen to any store deserialization failure, or is that a separate migration concern? |
Dexie upgrades can leave headers while settings (and the version key) are gone. Persisting the new version alone lets newer deserializers read incompatible rows; wipe first in that case. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Thanks @Mustdzyl — good catch on the upgrade direction.
Pushed a follow-up that resets when Widening the |
Fixes #349. Reset IndexedDB on version downgrade (e.g. 0.16.0-rc.x to 0.15.9). Patch upgrades within same major.minor keep the store. README documents pinning @0.15.9 while latest is RC. 317 idxdb-store tests pass.
Made with Cursor