From 4cb6bb4455171bd570890cc06187b8e4f4431904 Mon Sep 17 00:00:00 2001 From: Theo Browne Date: Sun, 6 Sep 2026 16:56:00 -0700 Subject: [PATCH] fix(server): run OpenCode CLI commands sequentially OpenCode CLI commands share one SQLite database, so running models, agent list, and skill discovery concurrently fails with "database is locked" and the provider does not start. Run the inventory commands one at a time in both the initial pass and the retry pass. Co-Authored-By: Claude Fable 5.1 --- apps/server/src/provider/opencodeRuntime.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/server/src/provider/opencodeRuntime.ts b/apps/server/src/provider/opencodeRuntime.ts index 19725d9472ca..ce2840f6c13d 100644 --- a/apps/server/src/provider/opencodeRuntime.ts +++ b/apps/server/src/provider/opencodeRuntime.ts @@ -945,10 +945,11 @@ const makeOpenCodeRuntime = Effect.gen(function* () { ...commandContext, }).pipe(Effect.exit); - // First attempt — run all inventory commands in parallel. + // Every OpenCode CLI command opens the same shared SQLite database. Running them + // concurrently causes "database is locked" failures, so run them one at a time. const [initialModelsResult, initialAgentsResult, initialSkillsResult] = yield* Effect.all( [runModelsCli(), runAgentsCli(), runSkillsCli()], - { concurrency: "unbounded" }, + { concurrency: 1 }, ); let modelsResult = initialModelsResult; let agentsResult = initialAgentsResult; @@ -966,7 +967,7 @@ const makeOpenCodeRuntime = Effect.gen(function* () { needsAgentsRetry ? runAgentsCli() : Effect.succeed(agentsResult), needsSkillsRetry ? runSkillsCli() : Effect.succeed(skillsResult), ], - { concurrency: "unbounded" }, + { concurrency: 1 }, ); modelsResult = m2; agentsResult = a2;