{"record":{"id":"0c19bbb14527e1a3","repo":"nexu-io/open-design","slug":"failed-to-spawn-vela-login","errorCode":null,"errorMessage":"failed to spawn vela login","messagePattern":"failed to spawn vela login","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/daemon/src/integrations/vela.ts","lineNumber":1231,"sourceCode":"      env,\n      detached: false,\n      windowsVerbatimArguments: invocation.windowsVerbatimArguments,\n    });\n  } catch (error) {\n    recordVelaAuthStage(\n      deps.attempt,\n      { stage: 'spawn_result', result: 'failed', errorKind: 'internal_error' },\n      'daemon',\n    );\n    throw error;\n  }\n  if (typeof child.pid !== 'number') {\n    recordVelaAuthStage(\n      deps.attempt,\n      { stage: 'spawn_result', result: 'failed', errorKind: 'internal_error' },\n      'daemon',\n    );\n    throw new Error('failed to spawn vela login');\n  }\n  activeLoginProcs.set(child.pid, child);\n  pendingVelaLoginTerminals += 1;\n  attemptState.currentPid = child.pid;\n  recordVelaAuthStage(\n    deps.attempt,\n    { stage: 'spawn_result', result: 'success' },\n    'daemon',\n  );\n  let spawnReturned = false;\n  let terminalHandled = false;\n  let activationCapture: VelaLoginActivationCapture | null = null;\n  let settleTerminal: (value: VelaLoginChildTerminal) => void = () => undefined;\n  const terminal = new Promise<VelaLoginChildTerminal>((resolve) => {\n    settleTerminal = resolve;\n  });\n  const handleTerminal = (\n    terminalKind: 'exit' | 'error',","sourceCodeStart":1213,"sourceCodeEnd":1249,"githubUrl":"https://github.com/nexu-io/open-design/blob/5be4028344c2eb4c667c5a97bda8f750c5597ef7/apps/daemon/src/integrations/vela.ts#L1213-L1249","documentation":"Raised in spawnVelaLoginAttempt() after child_process spawn returned a ChildProcess whose pid is not a number. Node sets pid only when the process actually started; a missing pid means spawn synchronously failed to launch (and an 'error' event will follow). Recorded as spawn_result failed/internal_error.","triggerScenarios":"spawn() returned without a pid — typically EAGAIN (out of processes/file descriptors), or a platform-specific spawn failure where Node could not fork/exec. Distinct from ENOENT (which surfaces via the 'error' event and is caught earlier).","commonSituations":"System at resource limits (max processes, fd ceiling); fork blocked by sandbox/seccomp; malformed env/args causing the launcher to fail before pid assignment; very rare race in packaged Electron spawn.","solutions":["Check ulimits (ulimit -u, ulimit -n) and raise them if the daemon is hitting ceilings.","Reduce concurrent agent spawns; the supervisor already single-flights login, but other agents may be saturating the process table.","If sandboxed, allow fork/exec for the vela binary path."],"exampleFix":"// before\nconst child = spawn(bin, args, spawnOpts);\nif (typeof child.pid !== 'number') throw new Error('failed to spawn vela login');\n\n// after\nconst child = spawn(bin, args, spawnOpts);\nif (typeof child.pid !== 'number') {\n  await once(child, 'error'); // surface the real errno from the 'error' event\n  throw new Error('failed to spawn vela login');\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isFailedToSpawn(err: unknown): boolean {\n  return err instanceof Error && err.message === 'failed to spawn vela login';\n}","tryCatchPattern":"try {\n  return await spawnVelaLoginAttempt(deps);\n} catch (err) {\n  if (err instanceof Error && err.message === 'failed to spawn vela login') {\n    // almost always resource limits — check ulimit -u / ulimit -n\n  }\n  throw err;\n}","preventionTips":["Raise process/fd ulimits for the daemon if it spawns many agents.","Sandbox: allow fork/exec for the vela binary path.","Listen for the child 'error' event to capture the real errno before the pid-check throw."],"tags":["login","integration","spawn","system-resources","vela"],"backgroundTag":null,"analyzedSha":"5be4028344c2eb4c667c5a97bda8f750c5597ef7","analyzedAt":"2026-08-12T12:03:58.812Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}