feat: add SQL schema version guard with migration confirmation parity - #4
Conversation
|
React Doctor found 12 issues in 3 files · 1 error & 11 warnings · score 69 / 100 (Needs work) · vs Errors
11 warnings
|
| } | ||
|
|
||
| for (const step of MIGRATIONS) { | ||
| if (step.version > currentVersion) await applyMigration(db, step.version, step.run) |
There was a problem hiding this comment.
React Doctor · react-doctor/async-await-in-loop (warning)
This makes the for…of loop slow because each await runs one after another, so collect the independent calls & run them together with await Promise.all(items.map(...))
Fix → Collect the items, then use await Promise.all(items.map(...)) so independent work runs at the same time
| @@ -169,6 +169,9 @@ export function Unlock(): ReactNode { | |||
| ) | |||
| setLoading(false) | |||
There was a problem hiding this comment.
React Doctor · react-doctor/no-loading-flag-reset-outside-finally (warning)
This resets a loading/busy flag only on the success path: if the awaited call rejects the reset never runs and the flag stays stuck truthy (a spinner that never stops, a button disabled forever). Move the reset into a finally block, or mirror it on every catch, so it clears on rejection too.
Fix → A trailing setLoading(false) after an await never runs if the awaited call rejects, so the flag stays stuck truthy; reset it in a finally block (or mirror the reset on every catch) so it clears on both paths.
Summary
schema_migrations: opening a vault whose schema is newer than what this build knows how to read now fails with a clear error (SCHEMA_VERSION_TOO_NEW) instead of silently misbehaving.reason: 'schema'), reusing the same optional-backup flow.confirmMigrationAndBackuphelper +mapOpenVaultErrorinipc-handlers.ts, used by both the header-version and schema-version gates.vault:open-with-recoveryto full behavioral parity withvault:open: previously it had zero version handling at all (no header-version prompt, no schema guard). Both are now identical.handleRecoveryUnlockinunlock.tsxdidn't special-case theMIGRATION_CANCELLEDsentinel like the password-unlock flow does, so canceling a migration during recovery-unlock would have leaked the raw sentinel as a visible error.Test plan
pnpm devwith a temporary no-opmigration_v2step (bumpingMAX_SCHEMA_VERSION1→2): opening a v1 test vault surfaced the schema-migration dialog through both password unlock and recovery unlock; Cancel and Confirm (with/without backup) all worked correctly.pnpm validatepasses.