{"record":{"id":"c138650818840f7d","repo":"diegosouzapw/OmniRoute","slug":"sqlite-file-is-unavailable-in-local-backup-restore","errorCode":null,"errorMessage":"SQLITE_FILE is unavailable in local backup restore","messagePattern":"SQLITE_FILE is unavailable in local backup restore","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/lib/db/backup.ts","lineNumber":440,"sourceCode":"          backupDirForPre,\n          `db_${new Date().toISOString().replace(/[:.]/g, \"-\")}_pre-restore.sqlite`\n        );\n        const dbForBackup = getDbInstance();\n        await dbForBackup.backup(preBackupPath);\n        _lastBackupAt = Date.now();\n      }\n    }\n  }\n\n  // Close and reset current connection\n  resetDbInstance();\n\n  // Clear all cached prepared statements and other state bound to the old connection\n  resetAllDbModuleState();\n\n  const sqliteFile = SQLITE_FILE;\n  if (!sqliteFile) {\n    throw new Error(\"SQLITE_FILE is unavailable in local backup restore\");\n  }\n\n  // On Windows, the file handle may be released asynchronously after close; give it a moment.\n  await sleep(500);\n\n  // Remove main file and WAL sidecars to avoid stale frame replay after restore.\n  // Retry unlink on EBUSY/EPERM (Windows may hold the handle briefly).\n  const sqliteFilesToReplace = [\n    sqliteFile,\n    `${sqliteFile}-wal`,\n    `${sqliteFile}-shm`,\n    `${sqliteFile}-journal`,\n  ];\n  for (const filePath of sqliteFilesToReplace) {\n    if (!filePath) continue;\n    await unlinkFileWithRetry(filePath);\n  }\n","sourceCodeStart":422,"sourceCodeEnd":458,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/lib/db/backup.ts#L422-L458","documentation":"Error \"SQLITE_FILE is unavailable in local backup restore\" thrown in diegosouzapw/OmniRoute.","triggerScenarios":"Thrown at src/lib/db/backup.ts:440 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"}