{"record":{"id":"2163ae325b5c39eb","repo":"Egonex-AI/Understand-Anything","slug":"a-report-transaction-path-already-exists","errorCode":null,"errorMessage":"A report transaction path already exists","messagePattern":"A report transaction path already exists","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/lib/large-repo-benchmark.mjs","lineNumber":951,"sourceCode":"    let lockDescriptor;\n    try {\n      lockDescriptor = fileSystem.openSync(lockPath, 'wx');\n      lockOwned = true;\n      fileSystem.closeSync(lockDescriptor);\n    } catch (error) {\n      if (!lockOwned) recovery.lockAcquisitionFailed = true;\n      throw error;\n    }\n    preflightReportTargets(\n      entries.map((entry) => entry.targetPath),\n      fileSystem,\n    );\n    for (const entry of entries) {\n      if (\n        fileSystem.existsSync(entry.tempPath) ||\n        fileSystem.existsSync(entry.backupPath)\n      ) {\n        throw new Error('A report transaction path already exists');\n      }\n      entry.hadOriginal = fileSystem.existsSync(entry.targetPath);\n      stageReportEntry(entry, fileSystem);\n    }\n    for (const entry of entries) {\n      if (entry.hadOriginal) {\n        fileSystem.renameSync(entry.targetPath, entry.backupPath);\n        entry.backupMoved = true;\n      }\n    }\n    for (const entry of entries) {\n      entry.installAttempted = true;\n      fileSystem.renameSync(entry.tempPath, entry.targetPath);\n    }\n    for (const entry of entries) {\n      if (entry.backupMoved) {\n        if (!tryRemove(entry.backupPath, fileSystem)) {\n          recovery.backupCleanupFailures += 1;","sourceCodeStart":933,"sourceCodeEnd":969,"githubUrl":"https://github.com/Egonex-AI/Understand-Anything/blob/32944829e7a63a9fa9c55d811d7f98a9530c6a6a/scripts/lib/large-repo-benchmark.mjs#L933-L969","documentation":"Thrown inside the report transaction after the pair lock is acquired but before staging begins. For each entry the harness checks whether its tempPath or backupPath already exists on disk; if either does, it refuses to proceed because the backup/temp files are how it rolls back atomically — a pre-existing leftover means a prior transaction was interrupted and the rename install could overwrite or shadow state unpredictably.","triggerScenarios":"A previous benchmark run crashed (SIGKILL, OOM, power loss) between staging and cleanup, leaving a .<name>.ua-report-<id>.tmp or .<name>.ua-report-<id>.backup file in the target directory. The next run acquires a fresh lock (the lock file was removed or never created) but finds the stranded temp/backup files and aborts.","commonSituations":"Interrupting a benchmark with Ctrl-C or killing the process during delivery. A CI runner that was preempted mid-run. Two concurrent benchmark runs targeting the same directory where one died. Manual experimentation that left .ua-report-*.tmp/.backup files behind.","solutions":["Inspect the target directory for leftover dotfiles: ls -la <report-dir> and look for .<basename>.ua-report-*.tmp and .<basename>.ua-report-*.backup.","Remove the leftovers once you confirm no live benchmark is running: rm -f '<dir>/.*.ua-report-*.{tmp,backup}'.","Re-run the benchmark; the transaction will stage cleanly.","If leftovers keep appearing, check that nothing (an editor, sync agent, watcher) is recreating them, and that prior runs are exiting normally."],"exampleFix":"// before — leftover from a crashed run blocks the next delivery\nls ./reports\n# .bench.json.ua-report-7c1f.tmp  .bench.json.ua-report-7c1f.backup  bench.json\n\n// after — clear stranded transaction files, then re-run\nrm -f ./reports/.*.ua-report-*.tmp ./reports/.*.ua-report-*.backup\nnode scripts/large-repo-benchmark.mjs --output ./reports/bench.json --markdown ./reports/bench.md","handlingStrategy":"validation","validationCode":"import { existsSync, readdirSync, rmSync } from 'node:fs';\nimport { join, basename, dirname } from 'node:path';\nfunction clearStrandedTransactionFiles(outputPath, markdownPath) {\n  const dirs = new Set([dirname(outputPath), dirname(markdownPath)]);\n  for (const dir of dirs) {\n    for (const name of readdirSync(dir)) {\n      if (/\\.ua-report-.*\\.(tmp|backup)$/.test(name)) {\n        rmSync(join(dir, name), { force: true });\n      }\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  deliverBenchmarkReports(opts);\n} catch (e) {\n  if (/path already exists/.test(e.message)) {\n    console.error('Stranded .ua-report-*.{tmp,backup} found — remove them and retry.');\n  }\n  throw e;\n}","preventionTips":["After any interrupted run, sweep .ua-report-*.tmp/.backup files from the report directory before the next run.","Avoid killing the benchmark during delivery; if you must, clean up transaction files afterwards.","Ensure only one benchmark targets a given report directory at a time."],"tags":["benchmark","filesystem","report-delivery","transaction","cleanup"],"backgroundTag":null,"analyzedSha":"32944829e7a63a9fa9c55d811d7f98a9530c6a6a","analyzedAt":"2026-08-12T10:25:44.261Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}