{"record":{"id":"aaa67e1d2030b084","repo":"JuliusBrussee/caveman","slug":"caveman-remote-session-revocation-was-unavailable","errorCode":null,"errorMessage":"caveman: remote session revocation was unavailable; credentials kept — retry `caveman logout`","messagePattern":"caveman: remote session revocation was unavailable; credentials kept — retry `caveman logout`","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/index.ts","lineNumber":9836,"sourceCode":"\t  const headers: Record<string, string> = {\n\t    authorization: `Bearer ${cfg.token}`,\n\t    \"x-cave-client\": \"cli\",\n\t  };\n\t  const request: RequestInit = {\n\t    method: \"POST\",\n\t    redirect: \"manual\",\n\t    headers,\n\t    signal: AbortSignal.timeout(5000),\n\t  };\n\t  if (cfg.refreshToken) {\n\t    headers[\"content-type\"] = \"application/json\";\n\t    request.body = JSON.stringify({ refresh_token: cfg.refreshToken });\n\t  }\n\t  let response: Response;\n\t  try {\n\t    response = await fetch(`${cfg.baseURL}/api/v1/auth/logout`, request);\n\t  } catch {\n\t    throw new Error(\"caveman: remote session revocation was unavailable; credentials kept — retry `caveman logout`\");\n\t  }\n\t  if (!response.ok) throw new Error(`caveman: remote session revocation failed (HTTP ${response.status}); credentials kept — retry \\`caveman logout\\``);\n\t}\n\tif (externalToken) {\n\t  console.error(\"caveman: remote session revoked; CAVE_TOKEN remains set by the parent environment — unset it before the next command\");\n\t  print({ logged_out: true, remote_session_revoked: true, external_token_cleared: false, external_token_source: \"CAVE_TOKEN\" });\n\t  return;\n\t}\n\t// Persist remote completion before deleting the only local credential. If\n\t// Keychain/file cleanup fails, the next logout safely retries cleanup without\n\t// trying to authenticate with the now-revoked session.\n\tawait saveConfig({ ...cfg, logoutPendingLocalCleanup: true });\n  clearToken(cfg.tokenStore);\n  await saveConfig({ baseURL: \"\", token: \"\" });\n  print({ logged_out: true });\n}\n\nfunction sleep(ms: number) {","sourceCodeStart":9818,"sourceCodeEnd":9854,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/cli/src/index.ts#L9818-L9854","documentation":"Thrown during `caveman logout` when the POST to `${baseURL}/api/v1/auth/logout` (remote session revocation) throws at the transport level — network failure, DNS error, or request abort. Local credentials are preserved so the logout can be retried.","triggerScenarios":"`caveman logout` with a stored refresh token when the auth server is unreachable: offline machine, wrong baseURL, server down, TLS interception, or connection reset mid-request.","commonSituations":"Logging out while offline or behind a blocking proxy; corporate firewall blocking the auth host; auth service outage; stale DNS after a gateway migration.","solutions":["Restore connectivity to the gateway and re-run `caveman logout`.","Verify the configured baseURL points at the correct, reachable auth host.","If behind a proxy/firewall, allowlist the auth endpoint or configure proxy env vars.","Retry later during a known outage; credentials were kept, so retrying is safe."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Check reachability of the auth logout endpoint first\nconst reachable = await fetch(`${baseURL}/api/v1/auth/logout`, { method: \"HEAD\", signal: AbortSignal.timeout(5000) }).then(r => true).catch(() => false);\nif (!reachable) console.warn(\"Skipping logout until the auth server is reachable.\");","typeGuard":null,"tryCatchPattern":"try {\n  await logout();\n} catch (e) {\n  if (e instanceof Error && e.message.includes(\"session revocation was unavailable\")) {\n    await new Promise(r => setTimeout(r, 3000));\n    await logout();\n  } else throw e;\n}","preventionTips":["Ensure network/proxy access to `${baseURL}` before running logout.","Update DNS/hosts after gateway migrations.","Credentials are kept on this error, so retrying is safe and idempotent."],"tags":["network","logout","session","http"],"backgroundTag":"network-request-failed","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}