decolua/9router · info
[DB] bun:sqlite unavailable: ${e.message}
Error message
[DB] bun:sqlite unavailable: ${e.message} What it means
First link in the SQLite driver fallback chain (src/lib/db/driver.js). tryBunSqlite only runs under the Bun runtime; if the built-in bun:sqlite adapter fails to import or initialize against DATA_FILE, it logs this warning and returns null so initAdapter falls through to better-sqlite3 / node:sqlite / sql.js. It is informational unless every driver in the chain fails.
Source
Thrown at src/lib/db/driver.js:14
import { ensureDirs, DATA_FILE } from "./paths.js";
// Use global to survive Next.js dev hot-reload (module state resets on reload)
if (!global._dbAdapter) global._dbAdapter = { instance: null, initPromise: null, logged: false };
const state = global._dbAdapter;
async function tryBunSqlite() {
// Bun runtime only — built-in, no install needed
if (!process.versions.bun) return null;
try {
const { createBunSqliteAdapter } = await import("./adapters/bunSqliteAdapter.js");
return await createBunSqliteAdapter(DATA_FILE);
} catch (e) {
console.warn(`[DB] bun:sqlite unavailable: ${e.message}`);
return null;
}
}
async function tryBetterSqlite() {
// Skip on Bun — better-sqlite3 native bindings unsupported
if (process.versions.bun) return null;
try {
const { createBetterSqliteAdapter } = await import("./adapters/betterSqliteAdapter.js");
return createBetterSqliteAdapter(DATA_FILE);
} catch (e) {
console.warn(`[DB] better-sqlite3 unavailable: ${e.message}`);
return null;
}
}
async function tryNodeSqlite() {
// Built-in since Node 22.5.0 — no install needed. Skip under Bun (no node:sqlite).View on GitHub (pinned to 90b52e06ff)
Solutions
- Check the logged e.message for the real cause (import failure vs file open error).
- Verify DATA_FILE's directory exists and is writable.
- Update Bun to a recent version (bun:sqlite is built-in and mature in current releases).
- If under Bun anyway, let the chain fall through — sql.js will be used; no action needed unless all drivers fail.
Defensive patterns
Strategy: fallback
Validate before calling
// Confirm which driver will be used at startup
if (process.versions.bun) console.log("Bun runtime — bun:sqlite expected"); Try / catch
try {
const adapter = await getAdapter();
console.log("DB ready with driver:", adapter.driver);
} catch (e) {
if (e.message.includes("No SQLite driver")) console.error("All SQLite drivers failed — check disk and install");
} Prevention
- Keep Bun up to date; bun:sqlite is built into current releases.
- Log the chosen adapter.driver at startup and alert on unexpected fallbacks.
- Ensure the data directory is writable so the driver can open DATA_FILE.
- Don't treat this warning as fatal — the chain falls through to sql.js.
When it happens
Trigger: Running under Bun while createBunSqliteAdapter throws: the dynamic import of ./adapters/bunSqliteAdapter.js fails, the DB file path is invalid/locked, or the database file is corrupt.
Common situations: Bun version with a broken or restricted bun:sqlite; DATA_FILE in an unwritable directory; corrupted existing 9router.db; bundled/packaged environment where the adapter file is missing.
Related errors
- [DB] node:sqlite unavailable: ${e.message}
- [DB] No SQLite driver available (bun/better/node/sql.js all
- [DB] better-sqlite3 unavailable: ${e.message}
- [DB] sql.js unavailable: ${e.message}
- [DB][sync] add column ${tableName}.${colName} failed: ${e.me
AI-assisted analysis of decolua/9router@90b52e06ff (2026-08-30).
Data as JSON: /api/errors/c9db131f41973817.
Report an issue: GitHub.