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

Function ghWithRetry

src/clawsweeper.ts:2085–2107  ·  view source on GitHub ↗
(args: string[], attempts = 12)

Source from the content-addressed store, hash-verified

2083}
2084
2085function ghWithRetry(args: string[], attempts = 12): string {
2086 let lastError: unknown;
2087 for (let attempt = 0; attempt < attempts; attempt += 1) {
2088 try {
2089 return gh(args);
2090 } catch (error) {
2091 lastError = error;
2092 const retryKind = ghRetryKind(error);
2093 if (retryKind === "none" || attempt === attempts - 1) throw error;
2094 const waitMs = ghRetryWaitMs(retryKind, attempt);
2095 const retryLabel =
2096 retryKind === "throttle" ? "GitHub throttled" : "Transient GitHub API failure";
2097 console.error(
2098 `${retryLabel}; retrying ${summarizeGhArgs(args)} in ${Math.round(waitMs / 1000)}s`,
2099 );
2100 if (retryKind === "throttle") {
2101 maybePublishThrottleHeartbeat({ args, attempt, attempts, waitMs });
2102 }
2103 sleepMs(waitMs);
2104 }
2105 }
2106 throw lastError;
2107}
2108
2109function ghRawWithRetry(args: string[], attempts = 12): string {
2110 let lastError: unknown;

Callers 15

ghJsonFunction · 0.85
ghJsonLinesFunction · 0.85
ghPageWithHeadersFunction · 0.85
postAssistCommentFunction · 0.85
ensurePriorityLabelFunction · 0.85
ensureImpactLabelFunction · 0.85
ensureMergeRiskLabelFunction · 0.85
syncPriorityLabelFunction · 0.85
syncImpactLabelsFunction · 0.85
syncMergeRiskLabelsFunction · 0.85

Calls 6

ghFunction · 0.85
ghRetryKindFunction · 0.85
ghRetryWaitMsFunction · 0.85
summarizeGhArgsFunction · 0.85
sleepMsFunction · 0.70

Tested by

no test coverage detected