Files
sql-server-query-ai/kb/Lazy database open.md
ahmed mohammedandClaude Opus 4.7 8b42a0931c docs: karpathy-pattern wiki built from the spec, plan, design contract and decisions ledger
kb/ is its own wiki root: 34 pages across 7 categories, index.md catalog, log.md, AGENTS.md schema layer, and raw/ holding copies of README, the spec, the 13-task plan, the design master and the SDD ledger.

Every page cross-references 3 to 6 others and all 107 wikilinks resolve except two [["list"]] artefacts inside JSON snippets in the copied plan.

Kept separate from the repository root on purpose: its generated graph lands in kb/.ua/ instead of overwriting the code graph.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-09-22 12:14:05 +03:00

751 B

Lazy database open

Opening SQLite at module import time broke npm run build with "database is locked": Next collects page data in parallel workers, each importing the module and running DDL at once.

The fix is a bound Proxy. Nothing opens until a property is first touched; then DatabaseSync is constructed, journal_mode = WAL and busy_timeout = 5000 are set, and the schema DDL runs once. The Proxy methods are bound to the real instance — an unbound Proxy made every call fail with "TypeError: Illegal invocation".

A second trap: SQLite rows arrive as null-prototype objects, which Next refuses to serialize from a server component to a client component. Rows are normalised on read.

Related: SQLite schema, Running locally.