Skip to content

Commit 6267f85

Browse files
committed
test(e2e): set busy_timeout on tag-owner-collision writable handles
The test opens a second writable bun:sqlite connection to the DB the live plugin process is actively using, but without busy_timeout it fails with 'database is locked' the instant the plugin holds the write lock (e.g. during its multi-second startup migration on slow CI disks). Mirror production (initializeDatabase PRAGMA busy_timeout=5000) so the handle waits out the concurrent writer instead of throwing immediately.
1 parent d9059a1 commit 6267f85

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

packages/e2e-tests/tests/tag-owner-collision.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@ describe("tag-owner collision repro (v3.3.1 Layer C)", () => {
100100
const sessionId = "ses-collision-repro";
101101
const dbPath = h.contextDb().filename;
102102
const writable = new Database(dbPath);
103+
// Mirror production (storage-db.ts initializeDatabase): wait out a
104+
// concurrent writer instead of throwing SQLITE_BUSY immediately. The
105+
// live plugin process holds the write lock during its startup
106+
// migration (which can take several seconds on slow CI disks), so a
107+
// pragma-less handle hits "database is locked" before it can insert.
108+
writable.exec("PRAGMA busy_timeout=5000");
103109
try {
104110
// Two tool tags: same callID `read:32`, different owners.
105111
// With composite identity these are DISTINCT rows. Pre-fix
@@ -156,6 +162,12 @@ describe("tag-owner collision repro (v3.3.1 Layer C)", () => {
156162
const sessionId = "ses-legacy-null";
157163
const dbPath = h.contextDb().filename;
158164
const writable = new Database(dbPath);
165+
// Mirror production (storage-db.ts initializeDatabase): wait out a
166+
// concurrent writer instead of throwing SQLITE_BUSY immediately. The
167+
// live plugin process holds the write lock during its startup
168+
// migration (which can take several seconds on slow CI disks), so a
169+
// pragma-less handle hits "database is locked" before it can insert.
170+
writable.exec("PRAGMA busy_timeout=5000");
159171
try {
160172
const insert = writable.prepare(
161173
"INSERT INTO tags (session_id, message_id, type, tag_number, byte_size, tool_name, tool_owner_message_id, harness) VALUES (?, ?, 'tool', ?, ?, 'read', NULL, 'opencode')",
@@ -182,6 +194,12 @@ describe("tag-owner collision repro (v3.3.1 Layer C)", () => {
182194
const sessionId = "ses-drop-isolation";
183195
const dbPath = h.contextDb().filename;
184196
const writable = new Database(dbPath);
197+
// Mirror production (storage-db.ts initializeDatabase): wait out a
198+
// concurrent writer instead of throwing SQLITE_BUSY immediately. The
199+
// live plugin process holds the write lock during its startup
200+
// migration (which can take several seconds on slow CI disks), so a
201+
// pragma-less handle hits "database is locked" before it can insert.
202+
writable.exec("PRAGMA busy_timeout=5000");
185203
try {
186204
const insert = writable.prepare(
187205
"INSERT INTO tags (session_id, message_id, type, tag_number, byte_size, tool_name, tool_owner_message_id, status, harness) VALUES (?, ?, 'tool', ?, ?, 'read', ?, 'active', 'opencode')",

0 commit comments

Comments
 (0)