fix: add busy_timeout pragma to prevent "database is locked" errors

SQLite was immediately returning SQLITE_BUSY when concurrent writes
collided (e.g., recordActivity firing from a timer during another write).
Adding a 5-second busy_timeout lets SQLite retry internally before failing.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
gsxdsm
2026-04-13 19:59:55 -07:00
parent 27e7a4389d
commit c2ddbdfb61
2 changed files with 4 additions and 0 deletions

View File

@@ -439,6 +439,8 @@ export class Database {
// Enable WAL mode for concurrent reader/writer access
this.db.exec("PRAGMA journal_mode = WAL");
// Wait up to 5s for locks to clear before returning SQLITE_BUSY
this.db.exec("PRAGMA busy_timeout = 5000");
// Enable foreign key enforcement
this.db.exec("PRAGMA foreign_keys = ON");
}