Skip to content

fix(opencode): retry server startup on transient SQLite 'database is locked' #18

Description

@nohat

Recent OpenCode threads fail immediately at first turn with:

OpenCode server exited before startup completed (code: 1). stderr: Error: Unexpected error — database is locked

4 occurrences Oct 3-4 in live userdata (projection_thread_activities kind provider.turn.start.failed). The failing step is startOpenCodeServerProcess (apps/server/src/provider/opencodeRuntime.ts) spawning opencode serve, which opens the shared OpenCode SQLite DB (~/.local/share/opencode/opencode.db, currently 5.1GB) and exits before printing its ready URL.

loadInventoryFromCli already serializes CLI commands and retries once on 'database is locked' (opencodeRuntime.ts). Server startup has no such guard — single attempt, fail, instant turn failure.

Proposed: retry server startup 2-3x with backoff when stderr/exit matches database-is-locked / SQLITE_BUSY, instead of failing the turn on first exit.

Diagnosed from live-DB forensics; agent harness openrouter/meta/muse-spark-1.3-contributor via T3 Code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions