{"record":{"id":"a0a5cd8ee058c91b","repo":"nexu-io/open-design","slug":"vela-login-exited-before-authentication-completed","errorCode":null,"errorMessage":"vela login exited before authentication completed (code ${result.code ?? 'null'}, signal ${result.signal ?? 'null'})","messagePattern":"vela login exited before authentication completed \\(code (.+?), signal (.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/daemon/src/integrations/vela.ts","lineNumber":1087,"sourceCode":"    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\n// explicit pre-activation exit/error triggers the proxy fallback.\nasync function waitForLoginActivationSteadyState(\n  capture: VelaLoginActivationCapture,\n  graceMs: number,","sourceCodeStart":1069,"sourceCodeEnd":1105,"githubUrl":"https://github.com/nexu-io/open-design/blob/5be4028344c2eb4c667c5a97bda8f750c5597ef7/apps/daemon/src/integrations/vela.ts#L1069-L1105","documentation":"Raised by waitForImmediateLoginFailure() when the direct vela login child exited within the grace window (no 'error' event) but never printed an activation URL. The message prefers captured stderr/stdout detail; the generic form embeds exit code and signal so the operator can tell a clean exit (code 0) from a signal kill.","triggerScenarios":"vela login runs, fails fast, and exits with a non-zero code (or is killed by a signal) before printing the device-auth URL. Capture has no activationUrl, so the generic message fires when stderr/stdout are empty.","commonSituations":"vela login prints help and exits because of an unknown flag in this binary version; vela self-updates and exits; sandbox/network policy kills the child (SIGTERM/SIGKILL); vela exits 0 but stdout buffering hid the URL.","solutions":["Read the captured stderr/stdout first — when present it identifies the real cause (unknown flag, expired session, etc.).","Re-run with a vela binary version matching the daemon's expected flags; or route through the IPv4 proxy fallback.","If signal is SIGKILL, investigate OOM / sandbox policy; if exit code is 2/64, check flag compatibility."],"exampleFix":"// before\nthrow new Error(`vela login exited before authentication completed (code ${result.code ?? 'null'}, signal ${result.signal ?? 'null'})`);\n\n// after (always surface captured detail for the operator)\nconst detail = (capture.stderr || capture.stdout).trim();\nthrow new Error(\n  detail || `vela login exited before authentication completed (code ${result.code ?? 'null'}, signal ${result.signal ?? 'null'})`,\n);","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isLoginExitedBeforeAuth(err: unknown): boolean {\n  return err instanceof Error\n    && /vela login exited before authentication completed/.test(err.message);\n}\n\nfunction extractExitCodeSignal(err: unknown): { code: string | null; signal: string | null } | null {\n  const m = err instanceof Error\n    ? err.message.match(/code (\\S+), signal (\\S+)\\)\\s*$/)\n    : null;\n  return m ? { code: m[1], signal: m[2] } : null;\n}","tryCatchPattern":"try {\n  await waitForImmediateLoginFailure(capture, terminal);\n} catch (err) {\n  const info = extractExitCodeSignal(err);\n  if (info && info.signal !== 'null') {\n    // external kill — do not auto-retry; investigate sandbox/OOM\n  }\n  throw err;\n}","preventionTips":["Always read capture.stderr/stdout first — the generic message only fires when they are empty.","Match the vela binary version to the flags the daemon expects.","Use the IPv4 proxy fallback when the direct path keeps exiting early."],"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"}