From 8121d8aa51caf28564b1038415023aae853c991d Mon Sep 17 00:00:00 2001 From: Oleg Date: Sun, 26 Jul 2026 17:34:48 +0000 Subject: [PATCH] Add busy_timeout pragma to avoid SQLITE_BUSY during docker build MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Next's build-time page-data collection evaluates route modules across multiple worker processes concurrently. On a fresh (empty) data volume — as in a clean docker build — two workers racing to create/open db.sqlite for the first time hit SQLITE_BUSY instead of just waiting the few ms for the other's lock. Reproduced by this session's docker build after adding the attachments route; local builds never hit it since the dev data/ directory already existed. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01QcXH24ky6zjk2UyK5oZUPH --- src/lib/db/client.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lib/db/client.ts b/src/lib/db/client.ts index 880f337..993a134 100644 --- a/src/lib/db/client.ts +++ b/src/lib/db/client.ts @@ -10,6 +10,11 @@ fs.mkdirSync(dataDir, { recursive: true }); const sqlite = new Database(path.join(dataDir, "db.sqlite")); sqlite.pragma("journal_mode = WAL"); sqlite.pragma("foreign_keys = ON"); +// Next's build-time page-data collection evaluates route modules across +// several worker processes concurrently — without this, two workers +// racing to open/initialize a fresh db.sqlite can throw SQLITE_BUSY +// instead of just waiting the few ms for the other's lock to clear. +sqlite.pragma("busy_timeout = 5000"); export const db = drizzle(sqlite, { schema }); export type DB = typeof db;