{"record":{"id":"3a6368d5f8a8c8d1","repo":"stablyai/orca","slug":"benchmark-exact-command-cleanup-failed","errorCode":null,"errorMessage":"Benchmark exact-command cleanup failed","messagePattern":"Benchmark exact-command cleanup failed","errorType":"exception","errorClass":"AggregateError","httpStatus":null,"severity":"error","filePath":"config/scripts/macos-computer-helper-owner-loss-processes.mjs","lineNumber":96,"sourceCode":"      expectedCommandFragments\n    )\n    if (remaining.length > 0) {\n      errors.push(\n        new Error(\n          `Benchmark helper cleanup left matching processes: ${remaining\n            .map((identity) => identity.pid)\n            .join(', ')}`\n        )\n      )\n    }\n  } catch (error) {\n    errors.push(error)\n  }\n  if (errors.length === 1) {\n    throw errors[0]\n  }\n  if (errors.length > 1) {\n    throw new AggregateError(errors, 'Benchmark exact-command cleanup failed')\n  }\n  return true\n}\n\nfunction sleepSync(milliseconds) {\n  Atomics.wait(sleepBuffer, 0, 0, milliseconds)\n}\n\nfunction validateDetachedIdentity(identity, expectedCommandFragment) {\n  if (\n    !Number.isInteger(identity?.pid) ||\n    identity.pid <= 0 ||\n    identity.pgid !== identity.pid ||\n    typeof identity.command !== 'string' ||\n    !identity.command.includes(expectedCommandFragment)\n  ) {\n    throw new Error('Recorded benchmark helper identity is invalid')\n  }","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/config/scripts/macos-computer-helper-owner-loss-processes.mjs#L78-L114","documentation":"killProcessMatchingCommand collects errors from two phases: killing each matching process, and a post-kill recheck for remaining matches. If two or more errors accumulate across these phases, they are wrapped in an AggregateError with this message. A single error is re-thrown as-is.","triggerScenarios":"Multiple helper processes match the command fragments, and killing several fails (e.g., EPERM on some, ESRCH on others); or the kill succeeds but the recheck ps call also fails. errors.length > 1 at line 95.","commonSituations":"Leftover helper processes from a previous crashed trial; processes owned by a different user (EPERM); zombies that cannot be signaled; ps during recheck fails due to buffer overflow with many processes.","solutions":["Inspect AggregateError.errors array for individual failure reasons (EPERM, ESRCH, etc.)","Run `ps -axo pid,pgid,command` and grep for the helper path to identify leftover processes","Kill leftover processes manually with `kill -9 <pid>`","Ensure trials clean up properly to avoid accumulation across runs"],"exampleFix":"// before: cleanup errors are opaque\ntry {\n  killProcessMatchingCommand([helperPath])\n} catch (e) {\n  console.error(e.message) // 'Benchmark exact-command cleanup failed'\n}\n\n// after: inspect individual errors from the aggregate\ntry {\n  killProcessMatchingCommand([helperPath])\n} catch (e) {\n  if (e instanceof AggregateError) {\n    for (const sub of e.errors) console.error(sub.code, sub.message)\n  }\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  killProcessMatchingCommand([helperPath])\n} catch (error) {\n  if (error instanceof AggregateError) {\n    for (const sub of error.errors) {\n      if (sub.code === 'ESRCH') continue // process already gone — benign\n      console.error('Cleanup failure:', sub.code, sub.message)\n    }\n  } else if (error.code !== 'ESRCH') {\n    throw error\n  }\n}","preventionTips":["Ensure each trial cleans up its helper processes to prevent accumulation","Inspect AggregateError.errors to distinguish EPERM (permission) from ESRCH (already gone)","Run ps to identify leftover processes before invoking cleanup"],"tags":["cleanup","process-lifecycle","aggregate-error"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}