{"record":{"id":"ce96df1faf058de4","repo":"diegosouzapw/OmniRoute","slug":"db-periodic-wal-truncate-failed","errorCode":null,"errorMessage":"[DB] Periodic WAL truncate failed:","messagePattern":"\\[DB\\] Periodic WAL truncate failed:","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/lib/db/core.ts","lineNumber":1016,"sourceCode":"// file itself; only wal_checkpoint(TRUNCATE) does, and a long-running server never closes its DB.\nfunction startWalTruncateScheduler(db: SqliteDatabase) {\n  clearWalTruncateScheduler();\n  if (isCloud || isBuildPhase || isAutomatedTestProcess()) return;\n\n  const intervalMs = getWalTruncateIntervalMs();\n  if (intervalMs <= 0) return;\n\n  walTruncateTimer = setInterval(() => {\n    try {\n      if (!db.open) return;\n      // TRUNCATE waits for readers; under concurrent write load it can no-op without\n      // shrinking the file. That is expected — it retries on the next tick.\n      if (checkpointDb(db, \"TRUNCATE\")) {\n        console.log(\"[DB] Periodic SQLite WAL checkpoint completed (TRUNCATE).\");\n      }\n    } catch (error: unknown) {\n      const message = error instanceof Error ? error.message : String(error);\n      console.warn(\"[DB] Periodic WAL truncate failed:\", message);\n    }\n  }, intervalMs);\n  walTruncateTimer.unref?.();\n}\n\nexport function runManagedDbHealthCheck(options?: { autoRepair?: boolean }) {\n  const db = getDbInstance();\n  return runDbHealthCheck(db, {\n    autoRepair: options?.autoRepair === true,\n    expectedSchemaVersion: \"1\",\n    createBackupBeforeRepair: () => createHealthCheckBackup(db),\n  });\n}\n\nexport function getDbInstance(): SqliteDatabase {\n  const existing = getDb();\n  if (existing) return existing;\n","sourceCodeStart":998,"sourceCodeEnd":1034,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/lib/db/core.ts#L998-L1034","documentation":"Error \"[DB] Periodic WAL truncate failed:\" thrown in diegosouzapw/OmniRoute.","triggerScenarios":"Thrown at src/lib/db/core.ts:1016 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"}