Tauri: persisted collection startup fails with duplicate column name: replay_json #1711
Send to my agent- I've validated the bug against the latest version of DB packages
Describe the bug On Tauri, a persisted collection fails to start up. The console logs, on load:
Failed persisted loopback startup: "error returned from database: (code: 1) duplicate column name: replay_json" (persisted.ts:2561)
Startup runs ALTER TABLE applied_tx ADD COLUMN replay_json, whose "duplicate column" error is expected and is meant to be swallowed by isDuplicateColumnAddError. That guard returns early unless the error is an Error instance (if (!(error instanceof Error)) return false). Tauri's @tauri-apps/plugin-sql rejects with a plain string, so the guard returns false and the error propagates. Reproduces on a fresh database. Drivers that throw real Errors (browser) aren't affected.
To Reproduce Minimal repro: https://github.com/DanBokete/tanstack-db-tauri-replay-json-repro
- pnpm install
- pnpm tauri dev
- Open the console - the error appears immediately on startup (no interaction needed)
Expected behavior The redundant ADD COLUMN should be a no-op (as on other drivers) and the collection should start up cleanly.
Screenshots
Desktop (please complete the following information):
- OS: macOS
- Browser N/A - Tauri (system WebView)
- Version
@tanstack/tauri-db-sqlite-persistence0.2.9,@tanstack/db-sqlite-persistence-core0.2.9,@tauri-apps/plugin-sql2.4.0, Tauri 2
Smartphone (please complete the following information):
- N/A
Additional context
Likely fix - normalize before matching so non-Error rejections are handled:
const rawMessage = error instanceof Error ? error.message : String(error)
I have a fix + regression test ready and am happy to open a PR - although you may prefer to normalize rejections in the Tauri driver instead. Happy to go whichever way you prefer.
KyleAMathews(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.