* Single GET request with retry. Returns the parsed response body * on success, null if all retries are exhausted.
(
url: string,
authHeaders: Record<string, string>,
context: string,
)
| 903 | * on success, null if all retries are exhausted. |
| 904 | */ |
| 905 | private async getWithRetry<T>( |
| 906 | url: string, |
| 907 | authHeaders: Record<string, string>, |
| 908 | context: string, |
| 909 | ): Promise<T | null> { |
| 910 | for (let attempt = 1; attempt <= 10; attempt++) { |
| 911 | let response |
| 912 | try { |
| 913 | response = await this.http.get<T>(url, { |
| 914 | headers: { |
| 915 | ...authHeaders, |
| 916 | 'anthropic-version': '2023-06-01', |
| 917 | 'User-Agent': getClaudeCodeUserAgent(), |
| 918 | }, |
| 919 | validateStatus: alwaysValidStatus, |
| 920 | timeout: 30_000, |
| 921 | }) |
| 922 | } catch (error) { |
| 923 | logForDebugging( |
| 924 | `CCRClient: GET ${url} failed (attempt ${attempt}/10): ${errorMessage(error)}`, |
| 925 | { level: 'warn' }, |
| 926 | ) |
| 927 | if (attempt < 10) { |
| 928 | const delay = |
| 929 | Math.min(500 * 2 ** (attempt - 1), 30_000) + Math.random() * 500 |
| 930 | await sleep(delay) |
| 931 | } |
| 932 | continue |
| 933 | } |
| 934 | |
| 935 | if (response.status >= 200 && response.status < 300) { |
| 936 | return response.data |
| 937 | } |
| 938 | if (response.status === 409) { |
| 939 | this.handleEpochMismatch() |
| 940 | } |
| 941 | logForDebugging( |
| 942 | `CCRClient: GET ${url} returned ${response.status} (attempt ${attempt}/10)`, |
| 943 | { level: 'warn' }, |
| 944 | ) |
| 945 | |
| 946 | if (attempt < 10) { |
| 947 | const delay = |
| 948 | Math.min(500 * 2 ** (attempt - 1), 30_000) + Math.random() * 500 |
| 949 | await sleep(delay) |
| 950 | } |
| 951 | } |
| 952 | |
| 953 | logForDebugging('CCRClient: GET retries exhausted', { level: 'error' }) |
| 954 | logForDiagnosticsNoPII('error', 'cli_worker_get_retries_exhausted', { |
| 955 | context, |
| 956 | }) |
| 957 | return null |
| 958 | } |
| 959 | |
| 960 | /** |
| 961 | * Report delivery status for a client-to-worker event. |
nothing calls this directly
no test coverage detected