feat: add async SQLite on Node 24 and improve messaging diagnostics (#520)
Move database work off the main thread on Node.js 24 and improve message handling and runtime diagnostics. Preserve migration, restart, and concurrency coverage with the async SQLite driver.
This commit is contained in:
1 parent
20f48d11ec
commit
c7428363cb
170 files changed
+7748
-3913
No files matched your search
@@ -1,22 +1,6 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { DatabaseSync } from 'node:sqlite';
|
||||
import { SqliteDatabase } from '@snowluma/sqlite';
|
||||
|
||||
/**
|
||||
* Open a SQLite database with the store-wide defaults: ensure the parent
|
||||
* directory exists, then open with WAL journaling + NORMAL synchronous — the
|
||||
* durability/throughput balance the message / media / reaction stores all
|
||||
* want. The caller owns schema init and any path munging.
|
||||
*
|
||||
* Concentrates the bootstrap each store previously hand-copied verbatim, so a
|
||||
* PRAGMA / journal-mode / busy-timeout change lands in one place instead of
|
||||
* three.
|
||||
*/
|
||||
export function openSqliteDb(dbPath: string): DatabaseSync {
|
||||
fs.mkdirSync(path.dirname(dbPath), { recursive: true });
|
||||
const db = new DatabaseSync(dbPath);
|
||||
db.exec('PRAGMA journal_mode = WAL');
|
||||
db.exec('PRAGMA synchronous = NORMAL');
|
||||
db.exec('PRAGMA busy_timeout = 1000');
|
||||
return db;
|
||||
/** Opens asynchronously with the shared WAL, durability and busy-timeout defaults. */
|
||||
export function openSqliteDb(dbPath: string): SqliteDatabase {
|
||||
return new SqliteDatabase(dbPath);
|
||||
}
|
||||
Reference in new issue
Block a user