fix(cli): handle sqlite lock errors

This commit is contained in:
marius-kilocode
2026-08-05 10:25:56 +02:00
parent 974f03203a
commit c9199cb529
5 changed files with 67 additions and 2 deletions
@@ -0,0 +1,30 @@
import { describe, expect, test } from "bun:test"
import { LockTimeoutError, SqlError, UnknownError } from "effect/unstable/sql/SqlError"
import { busyMessage, isBusy } from "@/kilocode/database/sqlite-error"
describe("SQLite errors", () => {
test("recognizes lock timeouts as busy database errors", () => {
const error = new SqlError({
reason: new LockTimeoutError({
cause: new Error("database is locked"),
message: "Failed to execute statement",
operation: "execute",
}),
})
expect(isBusy(error)).toBe(true)
expect(busyMessage).toBe("Database is busy. Please try again in a moment.")
})
test("does not classify other SQLite errors as busy", () => {
const error = new SqlError({
reason: new UnknownError({
cause: new Error("constraint failed"),
message: "Failed to execute statement",
operation: "execute",
}),
})
expect(isBusy(error)).toBe(false)
})
})