{"record":{"id":"2cf6282d94eef97a","repo":"diegosouzapw/OmniRoute","slug":"mcp-audit-better-sqlite3-binding-unavailable-f","errorCode":null,"errorMessage":"[MCP Audit] better-sqlite3 binding unavailable — fell back to node:sqlite (${nativeMessage.split(\"\\n\")[0]})","messagePattern":"\\[MCP Audit\\] better-sqlite3 binding unavailable — fell back to node:sqlite \\((.+?)\\)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"open-sse/mcp-server/audit.ts","lineNumber":259,"sourceCode":"  const { DatabaseSync } = (await import(\"node:sqlite\")) as {\n    DatabaseSync: new (p: string) => NodeSqliteDatabase;\n  };\n  return createNodeSqliteAuditAdapter(new DatabaseSync(dbPath));\n}\n\nasync function openFallbackAuditDb(dbPath: string, nativeMessage: string): Promise<AuditDatabase | null> {\n  if (!nodeSqliteFallbackAvailable()) {\n    console.error(\n      `[MCP Audit] better-sqlite3 native binding unavailable and Node ${process.version} ` +\n        \"has no built-in sqlite. Audit logging disabled. Fix: run \" +\n        \"`npm rebuild better-sqlite3` in the omniroute install root.\"\n    );\n    return null;\n  }\n\n  try {\n    const adapter = await openNodeSqliteAuditDb(dbPath);\n    console.warn(\n      `[MCP Audit] better-sqlite3 binding unavailable — fell back to node:sqlite ` +\n        `(${nativeMessage.split(\"\\n\")[0]})`\n    );\n    return adapter;\n  } catch (nodeErr) {\n    const nodeMessage = nodeErr instanceof Error ? nodeErr.message : String(nodeErr);\n    console.error(\"[MCP Audit] Failed to connect to database:\", nodeMessage);\n    return null;\n  }\n}\n\n/**\n * Lazy-load the database connection.\n * Uses the same SQLite database as the main OmniRoute app.\n *\n * Driver priority:\n *   1. better-sqlite3 — fast native binding (when its compiled `.node`\n *      binary is present, see scripts/build/postinstall.mjs).","sourceCodeStart":241,"sourceCodeEnd":277,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/open-sse/mcp-server/audit.ts#L241-L277","documentation":"Sentinel warning logged when better-sqlite3's native binding failed to load and the audit layer is falling back to Node's built-in node:sqlite DatabaseSync. It fires from openFallbackAuditDb whenever the primary native module throws (typically a NODE_MODULE_VERSION mismatch after a Node upgrade, or a missing prebuilt binary), meaning audit logging continues but through a different driver.","triggerScenarios":"Thrown at open-sse/mcp-server/audit.ts:259 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Run `npm rebuild better-sqlite3` in the omniroute install root to rebuild the native binding for the current Node version.","Pin Node to a version with a matching better-sqlite3 prebuilt binary, or upgrade the better-sqlite3 dependency.","If on Node >=22.5, accept the node:sqlite fallback — it is functional but verify audit performance is acceptable."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}