MCPcopy Index your code
hub / github.com/codeaashu/claude-code / axiosGetWithRetry

Function axiosGetWithRetry

src/utils/teleport/api.ts:47–81  ·  view source on GitHub ↗
(
  url: string,
  config?: AxiosRequestConfig,
)

Source from the content-addressed store, hash-verified

45 * Uses exponential backoff: 2s, 4s, 8s, 16s (4 retries = 5 total attempts)
46 */
47export async function axiosGetWithRetry<T>(
48 url: string,
49 config?: AxiosRequestConfig,
50): Promise<AxiosResponse<T>> {
51 let lastError: unknown
52
53 for (let attempt = 0; attempt <= MAX_TELEPORT_RETRIES; attempt++) {
54 try {
55 return await axios.get<T>(url, config)
56 } catch (error) {
57 lastError = error
58
59 // Don't retry if this isn't a transient error
60 if (!isTransientNetworkError(error)) {
61 throw error
62 }
63
64 // Don't retry if we've exhausted all retries
65 if (attempt >= MAX_TELEPORT_RETRIES) {
66 logForDebugging(
67 `Teleport request failed after ${attempt + 1} attempts: ${errorMessage(error)}`,
68 )
69 throw error
70 }
71
72 const delay = TELEPORT_RETRY_DELAYS[attempt] ?? 2000
73 logForDebugging(
74 `Teleport request failed (attempt ${attempt + 1}/${MAX_TELEPORT_RETRIES + 1}), retrying in ${delay}ms: ${errorMessage(error)}`,
75 )
76 await sleep(delay)
77 }
78 }
79
80 throw lastError
81}
82
83// Types matching the actual Sessions API response from api/schemas/sessions/sessions.py
84export type SessionStatus = 'requires_action' | 'running' | 'idle' | 'archived'

Callers

nothing calls this directly

Calls 4

isTransientNetworkErrorFunction · 0.85
logForDebuggingFunction · 0.85
errorMessageFunction · 0.50
sleepFunction · 0.50

Tested by

no test coverage detected