Tauri: persisted collection startup fails with duplicate column name: replay_json
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 3.9k
- Forks
- 266
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 55
Description
- 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at persisted.ts:2561 and inspect isDuplicateColumnAddError, then reproduce with the linked Tauri example using pnpm install and pnpm tauri dev. Confirm the duplicate-column condition is handled for Tauri's rejection format, add or run the regression test mentioned in the issue, and verify the persisted collection starts without the startup error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- sqlite, typescript
- Domain
- database
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 76/100