diegosouzapw/OmniRoute · error · Error

[DB] Nenhum driver SQLite disponível para

Error message

[DB] Nenhum driver SQLite disponível para '${sqliteFile}'. Drivers testados: ${syncDrivers}, sql.js (falhou: ${preInitError}).

What it means

Fatal database-init error in openSqliteDatabase: every sync driver candidate (bun:sqlite or better-sqlite3/node:sqlite depending on runtime) failed to open the file AND the sql.js WASM fallback was attempted but its pre-initialization itself failed (preInitError). The real sql.js failure cause is surfaced instead of the misleading 'not pre-initialized yet' message (#7288).

Solutions

  1. Read preInitError in the message to fix the root sql.js WASM load problem (missing/invalid wasm asset, bad path)
  2. Verify the native driver builds/installs for the runtime (better-sqlite3 native module vs bun:sqlite)
  3. Check that sqliteFile points to a writable, valid path and that DATA_DIR exists
  4. After fixing the WASM init, restart the process so ensureDbInitialized() can complete
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at src/lib/db/core.ts:207 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25). Data as JSON: /api/errors/05650e87d51bf165. Report an issue: GitHub.

Appendix: source

Thrown at src/lib/db/core.ts:207

  if (adapter.open) adapter.close();
}

function openSqliteDatabase(sqliteFile: string, options?: Record<string, unknown>): SqliteDatabase {
  const adapter = tryOpenSync(sqliteFile, options);
  if (adapter) return adapter;

  const sqlJs = getSqlJsAdapter(sqliteFile);
  if (sqlJs) return sqlJs;

  // sql.js pre-init was genuinely attempted (e.g. by the top-level eager
  // barrier below) and failed — surface the real cause instead of the
  // generic/misleading "not pre-initialized yet" message (#7288).
  const preInitError = getSqlJsPreInitError(sqliteFile);
  const syncDrivers = process.versions.bun
    ? "bun:sqlite (failed)"
    : "better-sqlite3 (failed), node:sqlite (unavailable)";
  if (preInitError) {
    throw new Error(
      `[DB] Nenhum driver SQLite disponível para '${sqliteFile}'. ` +
        `Drivers testados: ${syncDrivers}, ` +
        `sql.js (falhou: ${preInitError}).`
    );
  }

  throw new Error(
    `[DB] Nenhum driver SQLite disponível para '${sqliteFile}'. ` +
      "Chame ensureDbInitialized() no startup. " +
      `Drivers testados: ${syncDrivers}. ` +
      "sql.js WASM ainda não foi pré-inicializado."
  );
}

// Ensure data directory exists — with fallback for restricted home directories (#133)
if (!isCloud && !fs.existsSync(DATA_DIR)) {
  try {
    fs.mkdirSync(DATA_DIR, { recursive: true });

View on GitHub (pinned to a179ffed5b)