{"record":{"id":"11479d7485a3a162","repo":"stablyai/orca","slug":"electron-trial-and-cleanup-failed","errorCode":null,"errorMessage":"Electron trial and cleanup failed","messagePattern":"Electron trial and cleanup failed","errorType":"exception","errorClass":"AggregateError","httpStatus":null,"severity":"error","filePath":"config/scripts/macos-computer-helper-owner-loss-processes.mjs","lineNumber":178,"sourceCode":"  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}\n\nexport function benchmarkTrialNeedsCleanup(spawnResult, parsedResultAvailable) {\n  return spawnResult?.status !== 0 || !parsedResultAvailable\n}\n\nconst processGroupSignalOperations = {","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/config/scripts/macos-computer-helper-owner-loss-processes.mjs#L160-L196","documentation":"throwBenchmarkTrialFailures is called when both the Electron trial itself errored (trialError) and the subsequent cleanup also errored (cleanupError). It wraps both in an AggregateError so neither error is lost. This preserves the root-cause trial error alongside the cleanup failure for diagnosis.","triggerScenarios":"In runTrial (line 522): the Electron subprocess crashed, timed out, or produced no result (trialError set), AND the cleanup in the finally block also failed (cleanupError set from cleanupOwnerLossTrial). Both are non-null, so throwBenchmarkTrialFailures wraps them.","commonSituations":"Trial times out (Electron hangs) and leftover processes can't be killed; trial crashes and the result file doesn't exist, and temp dir cleanup also fails; the helper spawned but the sidecar died, leaving processes that cleanup can't reach.","solutions":["Inspect AggregateError.errors[0] (trial error) and errors[1] (cleanup error) separately — fix the trial error first","Read the trial's stdout.log and stderr.log in the launcher temp dir for the root cause of the trial failure","Manually clean up leftover processes so subsequent runs don't compound cleanup errors","Fixing the trial error often resolves the cleanup error (fewer leftover processes)"],"exampleFix":"// before: trial and cleanup errors are hard to separate\ntry {\n  const result = runTrial(executable, 'reaped')\n} catch (e) {\n  console.error(e.message) // 'Electron trial and cleanup failed'\n}\n\n// after: distinguish trial vs cleanup failures\ntry {\n  const result = runTrial(executable, 'reaped')\n} catch (e) {\n  if (e instanceof AggregateError) {\n    console.error('TRIAL:', e.errors[0]?.message)\n    console.error('CLEANUP:', e.errors[1]?.message)\n  }\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const result = runTrial(executable, 'reaped')\n} catch (error) {\n  if (error instanceof AggregateError && error.message.includes('trial and cleanup')) {\n    // Separate trial error from cleanup error for diagnosis\n    const [trialErr, cleanupErr] = error.errors\n    console.error('TRIAL:', trialErr.message)\n    console.error('CLEANUP:', cleanupErr.message)\n    // Fix the trial error first — it usually resolves cleanup too\n  }\n  throw error\n}","preventionTips":["Fix trial errors first — they are the root cause; cleanup errors are often secondary","Read the trial's stdout.log/stderr.log for root-cause diagnosis","Manually clean up leftover processes between failed runs to prevent compounding cleanup errors"],"tags":["cleanup","aggregate-error","trial"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}