{"record":{"id":"496536e6f0859a09","repo":"stablyai/orca","slug":"benchmark-trial-cleanup-failed","errorCode":null,"errorMessage":"Benchmark trial cleanup failed","messagePattern":"Benchmark trial cleanup failed","errorType":"exception","errorClass":"AggregateError","httpStatus":null,"severity":"error","filePath":"config/scripts/macos-computer-helper-owner-loss-processes.mjs","lineNumber":172,"sourceCode":"    detached: true,\n    killSignal: 'SIGKILL'\n  })\n}\n\nexport function runBenchmarkCleanupStages(stages) {\n  const errors = []\n  for (const stage of stages) {\n    try {\n      stage()\n    } catch (error) {\n      errors.push(error)\n    }\n  }\n  if (errors.length === 1) {\n    throw errors[0]\n  }\n  if (errors.length > 1) {\n    throw new AggregateError(errors, 'Benchmark trial cleanup failed')\n  }\n}\n\nexport function throwBenchmarkTrialFailures(trialError, cleanupError) {\n  if (trialError && cleanupError) {\n    throw new AggregateError([trialError, cleanupError], 'Electron trial and cleanup failed')\n  }\n  if (trialError) {\n    throw trialError\n  }\n  if (cleanupError) {\n    throw cleanupError\n  }\n}\n\nexport function parseBenchmarkTrialResult(serializedResult) {\n  return JSON.parse(serializedResult)\n}","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/config/scripts/macos-computer-helper-owner-loss-processes.mjs#L154-L190","documentation":"runBenchmarkCleanupStages executes an array of cleanup stage functions, catching each one's errors. If two or more stages throw, the errors are wrapped in an AggregateError with this message. A single stage failure re-throws that error directly.","triggerScenarios":"Multiple cleanup stages each throw — e.g., killRecordedProcess fails (process already gone or signal error) AND killProcessMatchingCommand also fails (leftover processes) AND temp dir removal fails (files still open). errors.length > 1 at line 171.","commonSituations":"A crashed trial leaves the system in a dirty state where multiple independent cleanup steps all fail; file descriptors still open preventing temp dir deletion; processes in D state that can't be killed.","solutions":["Inspect AggregateError.errors to identify which specific stages failed","Run cleanup stages independently to isolate failures — some may succeed on retry after the system settles","Ensure file descriptors are closed before temp directory cleanup","Manually clean up leftover processes and temp dirs between failed runs"],"exampleFix":"// before: all-or-nothing cleanup obscures individual stage failures\ntry {\n  runBenchmarkCleanupStages(stages)\n} catch (e) {\n  console.error(e.message)\n}\n\n// after: report each stage failure individually for diagnosis\ntry {\n  runBenchmarkCleanupStages(stages)\n} catch (e) {\n  if (e instanceof AggregateError) {\n    e.errors.forEach((err, i) => console.error(`Stage ${i}:`, err.message))\n  } else {\n    console.error(e.message)\n  }\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  runBenchmarkCleanupStages(stages)\n} catch (error) {\n  if (error instanceof AggregateError) {\n    // Report each stage failure — some may be benign (process already gone)\n    error.errors.forEach((err, i) => {\n      if (err.code === 'ESRCH') return\n      console.error(`Cleanup stage ${i} failed:`, err.message)\n    })\n  } else {\n    throw error\n  }\n}","preventionTips":["Design cleanup stages to be idempotent — re-running after partial failure should succeed","Close file descriptors before temp directory removal stages","Run stages in dependency order (kill processes before removing dirs)"],"tags":["cleanup","aggregate-error"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}