{"record":{"id":"57fdb85851bf1828","repo":"diegosouzapw/OmniRoute","slug":"db-wal-checkpoint-failed-during-close-checkpo","errorCode":null,"errorMessage":"[DB] WAL checkpoint failed during close (${checkpointMode}):","messagePattern":"\\[DB\\] WAL checkpoint failed during close \\((.+?)\\):","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/lib/db/core.ts","lineNumber":1437,"sourceCode":"}\n\nexport function closeDbInstance(options?: { checkpointMode?: CheckpointMode | null }): boolean {\n  clearDbHealthCheckScheduler();\n  clearWalTruncateScheduler();\n  const db = getDb();\n  if (!db) return false;\n\n  const checkpointMode = options?.checkpointMode ?? \"TRUNCATE\";\n\n  try {\n    if (checkpointMode) {\n      try {\n        if (checkpointDb(db, checkpointMode)) {\n          console.log(`[DB] SQLite WAL checkpoint completed (${checkpointMode}).`);\n        }\n      } catch (error: unknown) {\n        const message = error instanceof Error ? error.message : String(error);\n        console.warn(`[DB] WAL checkpoint failed during close (${checkpointMode}):`, message);\n      }\n    }\n  } finally {\n    try {\n      if (db.open) db.close();\n    } finally {\n      setDb(null);\n      // Module-level caches (prepared statements, schema-check memos — e.g.\n      // apiKeys.ts) are bound to the closed connection. Without this, a recreated\n      // DB (tests, backup restore of an older snapshot) hits \"no such column\"\n      // on the stale re-prepare path. backup.ts already does this on restore;\n      // close/reset must too (found by the 6A.1 orphan-test re-wire, 2026-06-09).\n      resetAllDbModuleState();\n    }\n  }\n\n  return true;\n}","sourceCodeStart":1419,"sourceCodeEnd":1455,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/lib/db/core.ts#L1419-L1455","documentation":"Error \"[DB] WAL checkpoint failed during close (${checkpointMode}):\" thrown in diegosouzapw/OmniRoute.","triggerScenarios":"Thrown at src/lib/db/core.ts:1437 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","schemaVersion":2},"datasetVersion":"2026-08-25T21:54:21.419Z"}