{"record":{"id":"36add56a3b289159","repo":"stablyai/orca","slug":"could-not-find-helper-owned-by-sidecar-sidecarpi","errorCode":null,"errorMessage":"Could not find helper owned by sidecar ${sidecarPid}","messagePattern":"Could not find helper owned by sidecar (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"config/scripts/macos-computer-helper-owner-loss-benchmark.mjs","lineNumber":178,"sourceCode":"    const output = execFileSync('ps', ['-axo', 'pid=,ppid=,pgid=,command='], {\n      encoding: 'utf8',\n      maxBuffer: 20 * 1024 * 1024\n    })\n    for (const line of output.split('\\n')) {\n      const match = line.trim().match(/^(\\d+)\\s+(\\d+)\\s+(\\d+)\\s+(.+)$/)\n      if (\n        match &&\n        Number(match[2]) === sidecarPid &&\n        Number(match[3]) === Number(match[1]) &&\n        match[4].includes(helperPath) &&\n        match[4].includes(' --agent ')\n      ) {\n        return { pid: Number(match[1]), pgid: Number(match[3]), command: match[4] }\n      }\n    }\n    await sleep(50)\n  }\n  throw new Error(`Could not find helper owned by sidecar ${sidecarPid}`)\n}\n\nfunction socketPathFromCommand(command) {\n  const match = command.match(/ --agent (.+?) --token-file /)\n  if (!match) {\n    throw new Error(`Could not read helper socket path from command: ${command}`)\n  }\n  return match[1]\n}\n\nfunction connectInvalidPeer(socketPath) {\n  return new Promise((resolve, reject) => {\n    const socket = net.createConnection(socketPath)\n    let accepted = false\n    const timeout = setTimeout(() => {\n      socket.destroy()\n      reject(new Error('Invalid-peer connection timed out'))\n    }, 5_000)","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/config/scripts/macos-computer-helper-owner-loss-benchmark.mjs#L160-L196","documentation":"waitForHelper polls process listings to find the computer-use helper child spawned by a sidecar (matching sidecar pid as pgid, helper pid, and a command line containing the helper path and ' --agent '). It throws when the helper never appears within the poll budget — i.e. the helper did not start or its process-tree shape does not match the regex assumptions.","triggerScenarios":"The sidecar failed to spawn the helper, the helper exited immediately, the platform's ps output format differs so the regex never matches, or the polling budget elapsed before the helper appeared (slow spawn).","commonSituations":"macOS version differences changing ps column layout, code-signing/notarization blocking the helper launch, a security policy killing the helper, or the helper binary path shifting so helperPath no longer matches.","solutions":["Run the sidecar manually and inspect its stderr/logs to see why the helper did not spawn.","Capture the ps output the poller reads and confirm the regex captures pid/pgid/command as expected on this macOS version.","Verify the helper binary exists at helperPath and is signed/notarized so it is not killed on launch.","Increase the poll budget if the helper is merely slow to appear."],"exampleFix":"// before\nthrow new Error(`Could not find helper owned by sidecar ${sidecarPid}`)\n\n// after (diagnostics)\nconst ps = readPsOutput()\nthrow new Error(`Could not find helper owned by sidecar ${sidecarPid}; ps lines=${ps.length}; matching children=${ps.filter(l => l.includes(String(sidecarPid))).length}`)","handlingStrategy":"retry","validationCode":"async function waitHelperOrDiagnose(sidecarPid, budgetMs) {\n  const start = Date.now()\n  while (Date.now() - start < budgetMs) {\n    const h = findHelper(sidecarPid); if (h) return h\n    await sleep(50)\n  }\n  throw new Error(`Helper not found; children=${readPs().filter(l => l.includes(String(sidecarPid))).length}`)\n}","typeGuard":"const isHelperRecord = (h) => h && Number.isInteger(h.pid) && typeof h.command === 'string'","tryCatchPattern":"try {\n  helper = await waitForHelper(sidecar.child.pid)\n} catch (e) {\n  if (/Could not find helper/.test(e.message)) { /* inspect sidecar stderr, raise budget, retry once */ }\n  throw e\n}","preventionTips":["Capture sidecar stderr so a failed helper spawn is visible.","Verify helper binary path and code-signing/notarization before the run.","Log the ps lines the poller scans to catch macOS format drift."],"tags":["process","helper","macos","benchmark","process-tree"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}