{"record":{"id":"22e2f0ee0b1aff3c","repo":"Egonex-AI/Understand-Anything","slug":"unable-to-write-benchmark-report-files","errorCode":null,"errorMessage":"Unable to write benchmark report files","messagePattern":"Unable to write benchmark report files","errorType":"exception","errorClass":"BenchmarkReportWriteError","httpStatus":null,"severity":"error","filePath":"scripts/lib/large-repo-benchmark.mjs","lineNumber":997,"sourceCode":"    for (const entry of entries) {\n      if (entry.tempCreated) {\n        if (!tryRemove(entry.tempPath, fileSystem)) {\n          recovery.tempCleanupFailures += 1;\n        }\n      }\n    }\n    if (lockOwned && !tryRemove(lockPath, fileSystem)) {\n      recovery.lockReleaseFailures += 1;\n    }\n  }\n\n  if (\n    deliveryFailed ||\n    recovery.tempCleanupFailures > 0 ||\n    recovery.backupCleanupFailures > 0 ||\n    recovery.lockReleaseFailures > 0\n  ) {\n    throw new BenchmarkReportWriteError(null, recovery);\n  }\n}\n\nfunction markdownValue(value) {\n  if (value === null || value === undefined) return 'n/a';\n  return String(value).replaceAll('|', '\\\\|').replaceAll(/\\r?\\n/g, ' ');\n}\n\nfunction metricRow(label, value) {\n  return `| ${label} | ${markdownValue(value)} |`;\n}\n\nfunction duration(value) {\n  return value === null || value === undefined ? 'n/a' : `${value} ms`;\n}\n\nfunction bytes(value) {\n  return value === null || value === undefined","sourceCodeStart":979,"sourceCodeEnd":1015,"githubUrl":"https://github.com/Egonex-AI/Understand-Anything/blob/32944829e7a63a9fa9c55d811d7f98a9530c6a6a/scripts/lib/large-repo-benchmark.mjs#L979-L1015","documentation":"BenchmarkReportWriteError thrown at the end of deliverBenchmarkReports when deliveryFailed is true OR any of the recovery cleanup counters (tempCleanupFailures, backupCleanupFailures, lockReleaseFailures) are non-zero. It is the catch-all for any failure in the staged write — the harness rolls back and then reports the partial state via the recovery object rather than leaving the caller with a silently-inconsistent filesystem.","triggerScenarios":"The outer try/catch in deliverBenchmarkReports caught any exception (set deliveryFailed=true and rolled back), OR the finally block could not remove a temp file, could not remove a backup file, or could not release the pair lock. The throw at line 997 converts that into a typed BenchmarkReportWriteError carrying the recovery counters.","commonSituations":"Read-only or out-of-space target directory (temp write fails, then cleanup of a half-written temp also fails). Antivirus / sync client holding file handles on Windows preventing unlink. Permission changed mid-run. The lock file could not be removed (e.g. directory permissions changed after acquisition). Disk full so writeFileSync partially wrote then rename failed.","solutions":["Free disk space and confirm write permission on the report directory, then re-run.","Examine error.recovery (lockAcquisitionFailed, tempCleanupFailures, backupCleanupFailures, lockReleaseFailures) — the specific non-zero counter points at which phase failed.","On Windows, close editors / disable sync clients (OneDrive, Dropbox) over the report directory so file handles release.","Remove any stranded .ua-report-*.tmp / .backup / lock files from the directory (see error 24) before retrying.","If the lock release failed, delete the lock file at reportPairLockPath(outputPath, markdownPath) manually once you are sure no other benchmark is running."],"exampleFix":"// before — caller treats all failures the same\ntry { deliverBenchmarkReports(opts); }\ncatch (e) { console.error('write failed'); }\n\n// after — inspect recovery to diagnose the phase\ntry { deliverBenchmarkReports(opts); }\ncatch (e) {\n  if (e instanceof BenchmarkReportWriteError) {\n    console.error('report write failed; recovery=', e.recovery);\n  } else throw e;\n}","handlingStrategy":"try-catch","validationCode":"import { accessSync, constants } from 'node:fs';\nfunction ensureReportDirWritable(outputPath, markdownPath) {\n  for (const p of [outputPath, markdownPath]) {\n    const dir = dirname(p);\n    accessSync(dir, constants.W_OK | constants.X_OK);\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  deliverBenchmarkReports(opts);\n} catch (e) {\n  if (e instanceof BenchmarkReportWriteError) {\n    console.error('report delivery failed; recovery =', e.recovery);\n    // recovery.lockAcquisitionFailed, .tempCleanupFailures,\n    // .backupCleanupFailures, .lockReleaseFailures pinpoint the phase\n  } else throw e;\n}","preventionTips":["Confirm the report directory is writable and has free space before running.","On Windows, exclude the report directory from sync clients and close editors that hold handles.","Inspect error.recovery to localise the failing phase instead of treating all failures identically."],"tags":["benchmark","filesystem","report-delivery","transaction","recovery"],"backgroundTag":null,"analyzedSha":"32944829e7a63a9fa9c55d811d7f98a9530c6a6a","analyzedAt":"2026-08-12T10:25:44.261Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}