{"record":{"id":"e20dd31c10248c1d","repo":"Egonex-AI/Understand-Anything","slug":"unable-to-remove-temporary-benchmark-artifacts","errorCode":null,"errorMessage":"Unable to remove temporary benchmark artifacts","messagePattern":"Unable to remove temporary benchmark artifacts","errorType":"exception","errorClass":"BenchmarkArtifactCleanupError","httpStatus":null,"severity":"warning","filePath":"scripts/lib/large-repo-benchmark.mjs","lineNumber":124,"sourceCode":"      backupCleanupFailures: recovery.backupCleanupFailures ?? 0,\n      lockReleaseFailures: recovery.lockReleaseFailures ?? 0,\n    };\n  }\n}\n\nexport class BenchmarkArtifactCleanupError extends Error {\n  constructor() {\n    super('Unable to remove temporary benchmark artifacts');\n    this.name = 'BenchmarkArtifactCleanupError';\n  }\n}\n\nexport function cleanupBenchmarkArtifacts(artifactRoot, operations = {}) {\n  const remove = operations.rmSync ?? rmSync;\n  try {\n    remove(artifactRoot, { recursive: true, force: true });\n  } catch {\n    throw new BenchmarkArtifactCleanupError();\n  }\n}\n\nfunction takeValue(argv, index, flag) {\n  const value = argv[index + 1];\n  if (!value || value.startsWith('--')) {\n    throw new CliUsageError(`${flag} requires a value`);\n  }\n  return value;\n}\n\nfunction parseConcurrency(value) {\n  return /^[0-9]+$/.test(value) ? Number(value) : Number.NaN;\n}\n\nfunction canonicalizePhysicalPath(pathValue) {\n  const lexicalPath = resolve(withoutExtendedWindowsPrefix(pathValue));\n  const missingComponents = [];","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/Egonex-AI/Understand-Anything/blob/32944829e7a63a9fa9c55d811d7f98a9530c6a6a/scripts/lib/large-repo-benchmark.mjs#L106-L142","documentation":"BenchmarkArtifactCleanupError is thrown by cleanupBenchmarkArtifacts when rmSync(artifactRoot, { recursive: true, force: true }) raises an exception. force:true already suppresses ENOENT, so a thrown error implies a deeper failure (EBUSY, EPERM, EMFILE, or a path that is not removable). The error is a typed class so callers can distinguish cleanup failures from stage or report errors.","triggerScenarios":"Removing a temp artifact directory that contains a file held open by another process; insufficient permissions on a file inside artifactRoot; running on Windows where recursive removal hits a locked handle; a path component being a device or special file.","commonSituations":"Benchmark workers still holding file handles when cleanup runs; antivirus or indexing locking files on Windows; running as a user lacking delete permission; leftover mount points or symlinks inside the artifact tree.","solutions":["Ensure all benchmark stage workers have fully exited before cleanup runs (await their completion).","Retry the removal once after a short delay to let the OS release handles, or re-run with --keep-artifacts and remove manually.","Check permissions on the artifactRoot and its contents; run as a user with delete rights.","On Windows, close any process (antivirus, editor, indexer) that may hold handles inside the temp directory."],"exampleFix":"// before\ncleanupBenchmarkArtifacts(artifactRoot);\n// after — retry once, then surface a typed error\ntry { cleanupBenchmarkArtifacts(artifactRoot); }\ncatch (e) {\n  if (e.name !== 'BenchmarkArtifactCleanupError') throw e;\n  await new Promise(r => setTimeout(r, 200));\n  cleanupBenchmarkArtifacts(artifactRoot);\n}","handlingStrategy":"try-catch","validationCode":"import { existsSync } from 'node:fs';\nif (existsSync(artifactRoot)) { /* safe to attempt cleanup */ } else { /* nothing to do */ }","typeGuard":"function isCleanupError(e: unknown): boolean {\n  return e instanceof Error && e.name === 'BenchmarkArtifactCleanupError';\n}","tryCatchPattern":"try { cleanupBenchmarkArtifacts(artifactRoot); }\ncatch (e) {\n  if (!isCleanupError(e)) throw e;\n  await new Promise(r => setTimeout(r, 200));\n  try { cleanupBenchmarkArtifacts(artifactRoot); }\n  catch { /* log and continue; artifacts are temporary */ }\n}","preventionTips":["Await all worker processes before cleanup so file handles are released.","On Windows, ensure no antivirus/indexer holds handles in the temp tree.","Use --keep-artifacts when debugging to inspect the temp directory manually."],"tags":["benchmark","filesystem","cleanup","windows"],"backgroundTag":null,"analyzedSha":"32944829e7a63a9fa9c55d811d7f98a9530c6a6a","analyzedAt":"2026-08-12T10:25:44.261Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}