{"record":{"id":"1c2d95bd483994e7","repo":"stablyai/orca","slug":"chromium-cookies-database-does-not-exist","errorCode":null,"errorMessage":"Chromium cookies database does not exist","messagePattern":"Chromium cookies database does not exist","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/main/browser/chromium-cookie-snapshot.ts","lineNumber":83,"sourceCode":"  )\n}\n\nfunction removeAttemptFiles(databasePath: string): void {\n  for (const suffix of ['', '-wal', '-shm'] as const) {\n    try {\n      unlinkSync(databasePath + suffix)\n    } catch {\n      /* best-effort between snapshot attempts */\n    }\n  }\n}\n\nfunction copyStableAttempt(sourcePath: string, databasePath: string): boolean {\n  const sourceWalPath = `${sourcePath}-wal`\n  const databaseBefore = readFileState(sourcePath)\n  const walBefore = readFileState(sourceWalPath)\n  if (!databaseBefore) {\n    throw new Error('Chromium cookies database does not exist')\n  }\n\n  removeAttemptFiles(databasePath)\n  // Why: #9355 — AV/EDR briefly opens a file literally named \"Cookies\" with FILE_SHARE_NONE,\n  // so an otherwise-fine copy throws EBUSY. The attempt loop below only handles a false\n  // return, so a throw here would escape it entirely.\n  copyFileWithWindowsRetry(sourcePath, databasePath)\n\n  if (walBefore) {\n    try {\n      // Why: SQLite only discovers a WAL whose basename exactly matches the DB.\n      copyFileWithWindowsRetry(sourceWalPath, `${databasePath}-wal`)\n    } catch (error) {\n      if (isMissingFileError(error)) {\n        return false\n      }\n      throw error\n    }","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/main/browser/chromium-cookie-snapshot.ts#L65-L101","documentation":"Thrown by copyStableAttempt() in chromium-cookie-snapshot.ts when readFileState(sourcePath) returns null, meaning statSync failed with ENOENT on the live Chromium Cookies database path. The function refuses to proceed because there is no source database to copy. This is distinct from a transient lock: the file genuinely does not exist at the expected path.","triggerScenarios":"Calling createChromiumCookieSnapshot() with a sourcePath that points to a non-existent Cookies file (wrong user-data dir, browser never ran and created a cookie store, profile dir was deleted between discovery and copy).","commonSituations":"Migrating cookies from a fresh profile that never visited any site. Pointing at the wrong Chromium user-data-dir (Default vs Profile 1). The browser was uninstalled/cleaned while Orca held a stale path. Snapshots taken after the user cleared browsing data and the DB was removed.","solutions":["Verify the sourcePath exists with fs.existsSync before calling createChromiumCookieSnapshot.","Confirm the Chromium profile directory and the 'Cookies' SQLite filename are correct (case-sensitive on Linux).","Launch the target browser once so Chromium creates the cookie database before snapshotting.","Treat a missing database as 'no cookies to import' (empty result) rather than a hard failure at the call site."],"exampleFix":"// before\nconst databaseBefore = readFileState(sourcePath)\nif (!databaseBefore) {\n  throw new Error('Chromium cookies database does not exist')\n}\n\n// after — caller-side guard\nif (!existsSync(sourcePath)) {\n  return { databasePath: '', cleanup: () => {} }\n}","handlingStrategy":"validation","validationCode":"import { existsSync } from 'node:fs'\n\nif (!existsSync(sourcePath)) {\n  return { databasePath: '', cleanup: () => {} } // treat as empty\n}","typeGuard":null,"tryCatchPattern":"try {\n  return createChromiumCookieSnapshot(sourcePath)\n} catch (error) {\n  if (error instanceof Error && error.message.includes('does not exist')) {\n    return { databasePath: '', cleanup: () => {} }\n  }\n  throw error\n}","preventionTips":["Stat the Cookies path before snapshotting.","Launch the source browser once so Chromium creates the cookie DB.","Resolve the profile dir from Chromium's Local State to pick the right Cookies path.","Treat a missing DB as 'no cookies' at the call site, not a hard error."],"tags":["chromium","cookies","filesystem","sqlite","enoent"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}