* Apply connection-level PRAGMAs. Shared by `initialize` and `open` so the two * paths can't drift. * * `busy_timeout` is set FIRST, before any pragma that might touch the database * file (notably `journal_mode`). If another process holds a write lock at open * time, the later pragmas — and the
(db: SqliteDatabase)
| 28 | * (e.g. the git-hook `codegraph sync` running while the MCP server writes). |
| 29 | */ |
| 30 | function configureConnection(db: SqliteDatabase): void { |
| 31 | db.pragma('busy_timeout = 5000'); // MUST be first — see above |
| 32 | db.pragma('foreign_keys = ON'); |
| 33 | db.pragma('journal_mode = WAL'); // node:sqlite supports WAL on every platform |
| 34 | db.pragma('synchronous = NORMAL'); // safe with WAL mode |
| 35 | db.pragma('cache_size = -64000'); // 64 MB page cache |
| 36 | db.pragma('temp_store = MEMORY'); // temp tables in memory |
| 37 | db.pragma('mmap_size = 268435456'); // 256 MB memory-mapped I/O |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Database connection wrapper with lifecycle management |
no test coverage detected