Repository navigation
fix(upload): read the session store when no codev process has it open - #378
Merged
Merged
Conversation
opencode.db runs in WAL mode. The Bun session reader opened it read-only, and a read-only connection cannot create the -wal/-shm side files a WAL read needs. While a codev process holds the store they exist; after the last one closes cleanly they are gone, and Bun's SQLite fails the first query with SQLITE_CANTOPEN — so `codev upload`, `codev upload --logs`, or a stats push with nothing else running found no sessions. The Bun driver now probes the read-only connection and, only on SQLITE_CANTOPEN, reopens read-write without create so SQLite recreates the side files as any WAL reader does; the reader still only runs SELECTs, and a missing store is never created. node:sqlite (the desktop sidecar's driver) already handles this case; the parity test now covers it for both drivers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Found while testing #377.
opencode.dbruns in WAL mode, and@codev/upload's Bun session reader opened it read-only. A read-only connection can't create the-wal/-shmside files that a WAL read needs:SQLITE_CANTOPEN.readAllSessions/readAllSessionStatsthen throw, the exporter logs "session store read failed", and the user sees "No sessions found". That hitscodev upload,codev upload --logsandcodev debug statswhenever nothing else is running.Reproduced on a copy of a real 52-session store with the side files removed: before the fix
SQLITE_CANTOPEN; after it, 52 sessions for both stats and log export.Fix (
packages/codev-upload/src/sqlite.bun.ts, fork-only, so noDIVERGENCES.mdrow):SQLITE_CANTOPEN, reopen with{ readwrite: true, create: false }so SQLite recreates the side files the way any reader of a WAL database does. The reader still only runsSELECTs, and a missing store is never created.node:sqlite(the desktop sidecar's driver) already handles this case, verified under Node 24. Its code is unchanged, and the parity test now covers it.Test plan
bun testinpackages/codev-upload(60 tests). New:bun typecheckinpackages/codev-uploadSQLITE_CANTOPENbefore, 52 sessions after🤖 Generated with Claude Code