From 2f16df8d175928724f614668d73d88f3f9cef878 Mon Sep 17 00:00:00 2001 From: sudacode Date: Sun, 5 Jul 2026 01:18:41 -0700 Subject: [PATCH] fix(history-db): treat SQLITE_CANTOPEN as readonly WAL retry error - Add `sqlite_cantopen` and `unable to open database file` to `isReadonlyWalRetryError` checks - Cover `SQLITE_CANTOPEN` case in test --- launcher/history-db.ts | 4 +++- launcher/history.test.ts | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/launcher/history-db.ts b/launcher/history-db.ts index 830a878f..2459da6c 100644 --- a/launcher/history-db.ts +++ b/launcher/history-db.ts @@ -58,7 +58,9 @@ export function isReadonlyWalRetryError(error: unknown, dbPath: string): boolean return ( text.includes('readonly') || text.includes('read-only') || - text.includes('attempt to write a readonly database') + text.includes('attempt to write a readonly database') || + text.includes('sqlite_cantopen') || + text.includes('unable to open database file') ); } diff --git a/launcher/history.test.ts b/launcher/history.test.ts index 1b5ed8b9..5d332652 100644 --- a/launcher/history.test.ts +++ b/launcher/history.test.ts @@ -300,6 +300,15 @@ test('isReadonlyWalRetryError only accepts readonly errors from WAL-mode databas ), true, ); + assert.equal( + isReadonlyWalRetryError( + Object.assign(new Error('unable to open database file'), { + code: 'SQLITE_CANTOPEN', + }), + walDbPath, + ), + true, + ); assert.equal( isReadonlyWalRetryError(new Error('no such table: imm_sessions'), walDbPath), false,