fix(desktop): stop opening the unused tanstack-db.sqlite at startup

Merged
SA
2mo ago
+0-84

Problem

A desktop install failed to start: the main process threw a SQLite corruption error while opening tanstack-db.sqlite, synchronously, inside the whenReady startup chain. The throw ended the chain before makeAppSetup, the tray and setupAutoUpdater ran, so the app came up with no window. The file stays corrupt, so every relaunch fails the same way, and because the auto-updater never starts, a new release can't reach that install either.

Root cause

The file is dead weight. #6328 replaced Electric sync with tRPC + React Query and deleted the renderer's createElectronSQLitePersistence / persistedCollectionOptions usage. The main process kept opening the database, switching it to WAL, checkpointing and possibly VACUUMing it, and exposing IPC handlers that nothing invokes. git grep finds no remaining consumer of either @tanstack/*-db-sqlite-persistence package outside persistence.ts.

Corruption itself is rare: this is the only event from this code path in 90 days. But when the file does get corrupted, it takes down a startup path whose output nobody uses.

Fix

Delete main/lib/persistence/persistence.ts, its init call and its quit-cleanup hook, and the two now-unused packages (bun.lock shrinks by exactly those plus their shared core). 84 deletions, no additions.

The orphaned tanstack-db.sqlite file on existing installs is left in place. Deleting it would be new code for a cosmetic gain.

Verification

$ bunx biome check apps/desktop/src/main/index.ts apps/desktop/src/main/lib/quit-sequence.ts apps/desktop/src/main/lib/quit-sequence.test.ts apps/desktop/package.json
Checked 4 files in 19ms. No fixes applied.

$ cd apps/desktop && bun run typecheck      # tsc --noEmit
tsc exit 0 (no output)

$ bun test src/main/lib/quit-sequence.test.ts
 6 pass
 0 fail
 12 expect() calls
Ran 6 tests across 1 file.

Not verified in a running app.

Refs DESKTOP-1AY


Summary by cubic

Stops the desktop app from opening tanstack-db.sqlite at startup, which crashed the app before any window appeared when the file was corrupt.

Since #6328 replaced Electric sync with tRPC + React Query, nothing consumed the SQLite persistence the main process exposed. The startup code opened the file synchronously, so a corrupt file aborted the whenReady chain; every relaunch failed the same way, and the auto-updater never started, so the install couldn't recover.

  • Removed persistence.ts, its quit hook, and the two unused @tanstack/*-db-sqlite-persistence packages.
  • The orphaned tanstack-db.sqlite file on existing installs is left in place.

Summary by CodeRabbit

  • Behavior Changes
    • The desktop app no longer uses its local database persistence mechanism. Other app state handling and the remaining steps in the quit process are unchanged.