{"record":{"id":"ac9d87b4cd459e18","repo":"nexu-io/open-design","slug":"vela-login-exited-before-device-authorization-star","errorCode":null,"errorMessage":"vela login exited before device authorization started (code ${result.code ?? 'null'}, signal ${result.signal ?? 'null'})","messagePattern":"vela login exited before device authorization started \\(code (.+?), signal (.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/daemon/src/integrations/vela.ts","lineNumber":1150,"sourceCode":"    timer.unref?.();\n    if (capture.activation.activationUrl) finish({ kind: 'activated' });\n  });\n  const result = await Promise.race([observed, terminal]);\n\n  if (result.kind === 'activated') return;\n  // `close` may win the Promise.race before the 50ms activation poll even\n  // though its final drained stdout chunk already populated the capture.\n  // Observed activation always owns this child; never launch a duplicate\n  // device-auth attempt merely because the child exited immediately after it.\n  if (capture.activation.activationUrl) return;\n  // Slow but still alive: leave the direct attempt running and let the request\n  // return — do NOT kill it or fall back to the proxy.\n  if (result.kind === 'still-running') return;\n  if (result.kind === 'error') {\n    throw new Error(`vela login failed to start: ${result.error.message}`);\n  }\n  const detail = (capture.stderr || capture.stdout).trim();\n  throw new Error(\n    detail ||\n      `vela login exited before device authorization started (code ${result.code ?? 'null'}, signal ${result.signal ?? 'null'})`,\n  );\n}\n\ninterface SpawnVelaLoginAttemptDeps extends SpawnVelaLoginDeps {\n  attempt: VelaLoginAttemptRef;\n  onLatePreActivationFailure?: () => Promise<void>;\n}\n\nasync function spawnVelaLoginAttempt(\n  deps: SpawnVelaLoginAttemptDeps,\n): Promise<SpawnedVelaLogin> {\n  const attemptState = currentVelaLoginAttempt(deps.attempt);\n  if (!attemptState) throw new Error('vela login attempt is no longer active');\n  if (hasRunningVelaLoginChild()) throw new Error('vela login already running');\n  const def = getAgentDef('amr');\n  if (!def) {","sourceCodeStart":1132,"sourceCodeEnd":1168,"githubUrl":"https://github.com/nexu-io/open-design/blob/5be4028344c2eb4c667c5a97bda8f750c5597ef7/apps/daemon/src/integrations/vela.ts#L1132-L1168","documentation":"Raised by the activation-wait path when the child exited cleanly (no 'error' event, no 'still-running') without ever emitting an activation URL, and stderr/stdout had no detail. Embeds exit code and signal for diagnosis. Distinct from 289 because this fires in the post-spawn activation wait, after the immediate-failure grace already passed.","triggerScenarios":"vela login ran past the grace window, then exited before printing the device-auth URL with no useful capture. Common when the child is killed externally mid-activation or exits with a code the parser did not treat as an error event.","commonSituations":"External kill (signal) during activation; vela printed the URL to a stream the capture is not reading; race where close wins before the 50ms activation poll reads the final chunk (the code already defends activationUrl, so this residual means capture truly had none).","solutions":["Inspect exit code/signal: a non-null signal almost always means external kill (sandbox/OOM/timeout).","Confirm the capture reads both stdout and stderr of the configured vela child.","Re-run with proxy fallback enabled so a flaky direct activation can be retried."],"exampleFix":"// before\nthrow new Error(`vela login exited before device authorization started (code ${result.code ?? 'null'}, signal ${result.signal ?? 'null'})`);\n\n// after\nconst detail = (capture.stderr || capture.stdout).trim();\nthrow new Error(\n  detail || `vela login exited before device authorization started (code ${result.code ?? 'null'}, signal ${result.signal ?? 'null'})`,\n);","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isExitedBeforeDeviceAuth(err: unknown): boolean {\n  return err instanceof Error\n    && /vela login exited before device authorization started/.test(err.message);\n}","tryCatchPattern":"try {\n  await waitForActivation(capture, observed, terminal);\n} catch (err) {\n  if (isExitedBeforeDeviceAuth(err)) {\n    // capture had no activationUrl and child exited; route to proxy fallback\n  }\n  throw err;\n}","preventionTips":["Confirm the capture reads both stdout and stderr of the configured child.","Treat a non-null signal as external kill before retrying.","Prefer the proxy fallback for environments where the direct path is killed mid-activation."],"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"}