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
This commit is contained in:
2026-07-05 01:18:41 -07:00
parent 651e541ea8
commit 2f16df8d17
2 changed files with 12 additions and 1 deletions
+3 -1
View File
@@ -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')
);
}
+9
View File
@@ -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,