{"record":{"id":"788588785e041476","repo":"nexu-io/open-design","slug":"vela-login-failed-to-start-result-error-message","errorCode":null,"errorMessage":"vela login failed to start: ${result.error.message}","messagePattern":"vela login failed to start: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/daemon/src/integrations/vela.ts","lineNumber":1083,"sourceCode":"  capture: VelaLoginActivationCapture,\n  terminal: Promise<VelaLoginChildTerminal>,\n): Promise<void> {\n  const result = await Promise.race<\n    VelaLoginChildTerminal | { kind: 'running' }\n  >([\n    terminal,\n    new Promise<{ kind: 'running' }>((resolve) => {\n      const timer = setTimeout(\n        () => resolve({ kind: 'running' }),\n        LOGIN_STARTUP_GRACE_MS,\n      );\n      timer.unref?.();\n    }),\n  ]);\n\n  if (result.kind === 'running') return;\n  if (result.kind === 'error') {\n    throw new Error(`vela login failed to start: ${result.error.message}`);\n  }\n  if (capture.activation.activationUrl) return;\n  const detail = (capture.stderr || capture.stdout).trim();\n  throw new Error(\n    detail ||\n      `vela login exited before authentication completed (code ${result.code ?? 'null'}, signal ${result.signal ?? 'null'})`,\n  );\n}\n\n// Wait for the direct `vela login` attempt to either print its device-auth\n// activation URL (healthy — the direct path works even on the transparent-proxy\n// networks this fix targets, just possibly slowly) or exit/error BEFORE printing\n// it (a real failure the caller can retry through the IPv4 proxy). Crucially, a\n// merely slow-but-still-running direct login is NOT killed: once the grace\n// elapses we simply stop blocking the request and let it keep running (the UI\n// polls /status). Killing a slow-healthy direct login and re-routing it through\n// the proxy is exactly the regression this avoids — on a corporate transparent\n// proxy the proxy hop loses the client IP and the upstream 502s. Only an","sourceCodeStart":1065,"sourceCodeEnd":1101,"githubUrl":"https://github.com/nexu-io/open-design/blob/5be4028344c2eb4c667c5a97bda8f750c5597ef7/apps/daemon/src/integrations/vela.ts#L1065-L1101","documentation":"Raised by waitForImmediateLoginFailure() when the vela login child emitted an 'error' event within the LOGIN_STARTUP_GRACE_MS window — i.e. the process failed to spawn or failed very early. result.error.message carries the underlying spawn error (ENOENT, EACCES, EAGAIN).","triggerScenarios":"Spawn errors before the grace timer elapses: binary missing (ENOENT), not executable (EACCES), or OS resource limits (EAGAIN). The direct login attempt fails before it can print a device-auth activation URL.","commonSituations":"VELA_BIN points at a non-existent path; vela not on PATH; binary exists but lacks execute permission; /tmp or process env in a broken state; packaged daemon lost access to the bundled binary.","solutions":["Inspect result.error.message: ENOENT → install vela or set VELA_BIN; EACCES → chmod +x the binary; EAGAIN → lower fd/memory pressure.","Ensure the amr agent def resolves a real selectedPath via resolveAgentLaunch.","If using the IPv4 proxy fallback path, the caller may still retry through it — make sure the fallback is enabled."],"exampleFix":"// before\nawait waitForImmediateLoginFailure(capture, terminal);\n\n// after\ntry {\n  await waitForImmediateLoginFailure(capture, terminal);\n} catch (err) {\n  if (/ENOENT|EACCES/.test(String(err))) {\n    // surface 'install vela or configure VELA_BIN' to the user, no retry\n  }\n  throw err;\n}","handlingStrategy":"try-catch","validationCode":"function isVelaBinPresent(bin = process.env.VELA_BIN): boolean {\n  if (!bin) return false;\n  try {\n    // cheap existence check; real exec check happens at spawn\n    return fs.statSync(bin).isFile();\n  } catch {\n    return false;\n  }\n}","typeGuard":"function isSpawnFailureMessage(err: unknown): boolean {\n  return err instanceof Error && err.message.startsWith('vela login failed to start:');\n}\n\nfunction underlyingErrno(err: unknown): string | null {\n  const m = err instanceof Error ? err.message.match(/\\b(ENOENT|EACCES|EAGAIN)\\b/) : null;\n  return m ? m[1] : null;\n}","tryCatchPattern":"try {\n  await waitForImmediateLoginFailure(capture, terminal);\n} catch (err) {\n  const errno = underlyingErrno(err);\n  if (errno === 'ENOENT' || errno === 'EACCES') {\n    // permanent — surface 'install vela or configure VELA_BIN', do not retry\n  }\n  throw err;\n}","preventionTips":["Ensure VELA_BIN resolves to an existing, executable binary before starting login.","Keep the amr agent runtime resolver able to find vela on PATH.","Distinguish permanent spawn errors (ENOENT/EACCES) from retriable ones."],"tags":["login","integration","spawn","vela"],"backgroundTag":null,"analyzedSha":"5be4028344c2eb4c667c5a97bda8f750c5597ef7","analyzedAt":"2026-08-12T12:03:58.812Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}