MCPcopy
hub / github.com/openclaw/clawsweeper / ghTextWithRetryAsync

Function ghTextWithRetryAsync

src/repair/github-cli.ts:169–186  ·  view source on GitHub ↗
(
  ghArgs: string[],
  options: GhRetryOptions | number = {},
)

Source from the content-addressed store, hash-verified

167}
168
169export async function ghTextWithRetryAsync(
170 ghArgs: string[],
171 options: GhRetryOptions | number = {},
172): Promise<string> {
173 const resolved = resolveRetryOptions(options);
174 const attempts = Math.max(1, resolved.attempts ?? 6);
175 let lastError: unknown;
176 for (let attempt = 1; attempt <= attempts; attempt += 1) {
177 try {
178 return await ghTextAsync(ghArgs, resolved);
179 } catch (error) {
180 lastError = error;
181 if (attempt >= attempts || !shouldRetryGh(error)) throw error;
182 await sleepAsync(Math.min(1000 * attempt, 5000));
183 }
184 }
185 throw lastError instanceof Error ? lastError : new Error(String(lastError));
186}
187
188export async function ghTextAsync(ghArgs: string[], options: GhRunOptions = {}): Promise<string> {
189 if (options.input !== undefined) return ghText(ghArgs, options);

Callers 1

ghJsonWithRetryAsyncFunction · 0.85

Calls 4

resolveRetryOptionsFunction · 0.85
ghTextAsyncFunction · 0.85
sleepAsyncFunction · 0.85
shouldRetryGhFunction · 0.70

Tested by

no test coverage detected