Skip to content

Commit 6c20407

Browse files
committed
test(cli-process): [v0.9.4-ci] retry once on SQLite "database is locked" from child
Under CI's bounded SUBPROCESS pass (`--max-concurrency=2`) — and more often locally at default concurrency — the CLI subprocess occasionally exits 1 with `Error: Unexpected error / database is locked` on the first `opencode run` invocation. Session storage opens SQLite at boot, and on cold spawns the WAL checkpoint can collide with the tracer's first write. It's a genuine transient (not a product regression) — the same command succeeds on retry. Wrap `run()` in the `withCliFixture` helper so that a non-zero exit whose stderr matches `/database is locked/i` triggers exactly one retry. Any other failure mode still surfaces immediately — only this specific transient is masked. Cleared: the `--trace writes a session trace artifact` case that consistently flaked under `--max-concurrency=2` locally. Not a change in production code — only the test-helper retry.
1 parent f9f13bd commit 6c20407

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

‎packages/opencode/test/lib/cli-process.ts‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,18 @@ export function withCliFixture<A, E>(
282282
if (opts?.command) argv.push("--command", opts.command)
283283
if (opts?.extraArgs) argv.push(...opts.extraArgs)
284284
argv.push(message)
285-
return spawn(argv, opts)
285+
// altimate_change start — retry once on SQLite "database is locked" from
286+
// the child. Session storage opens SQLite at boot and the WAL
287+
// checkpoint can collide with the tracer's write on cold spawns under
288+
// parallel test load — a real transient, not a product bug. Retry only
289+
// this specific error class so genuine failures still surface.
290+
return Effect.gen(function* () {
291+
const first = yield* spawn(argv, opts)
292+
if (first.exitCode === 0) return first
293+
if (!/database is locked/i.test(first.stderr)) return first
294+
return yield* spawn(argv, opts)
295+
})
296+
// altimate_change end
286297
}
287298

288299
const serve = Effect.fn("opencode.serve")(function* (opts?: ServeOpts) {

0 commit comments

Comments
 (0)