mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-09-19 10:02:04 +08:00
fix(cli): avoid startup database lock crashes
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import { describe, expect, test } from "bun:test"
|
||||
import { Cause } from "effect"
|
||||
import { LockTimeoutError, SqlError, UnknownError } from "effect/unstable/sql/SqlError"
|
||||
import { EffectDrizzleQueryError } from "drizzle-orm/effect-core/errors"
|
||||
import { busyMessage, isBusy } from "@/kilocode/database/sqlite-error"
|
||||
|
||||
describe("SQLite errors", () => {
|
||||
@@ -27,4 +29,22 @@ describe("SQLite errors", () => {
|
||||
|
||||
expect(isBusy(error)).toBe(false)
|
||||
})
|
||||
|
||||
test("recognizes lock timeouts wrapped by Drizzle", () => {
|
||||
const error = new EffectDrizzleQueryError({
|
||||
query: "update credential set value = ?",
|
||||
params: ["<redacted>"],
|
||||
cause: Cause.fail(
|
||||
new SqlError({
|
||||
reason: new LockTimeoutError({
|
||||
cause: new Error("database is locked"),
|
||||
message: "Failed to execute statement",
|
||||
operation: "execute",
|
||||
}),
|
||||
}),
|
||||
),
|
||||
})
|
||||
|
||||
expect(isBusy(error)).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user