(args: string[], attempts = 12)
| 2107 | } |
| 2108 | |
| 2109 | function ghRawWithRetry(args: string[], attempts = 12): string { |
| 2110 | let lastError: unknown; |
| 2111 | for (let attempt = 0; attempt < attempts; attempt += 1) { |
| 2112 | try { |
| 2113 | return run("gh", args); |
| 2114 | } catch (error) { |
| 2115 | lastError = error; |
| 2116 | const retryKind = ghRetryKind(error); |
| 2117 | if (retryKind === "none" || attempt === attempts - 1) throw error; |
| 2118 | const waitMs = ghRetryWaitMs(retryKind, attempt); |
| 2119 | console.error( |
| 2120 | `Transient GitHub workflow dispatch failure; retrying ${summarizeGhArgs(args)} in ${Math.round(waitMs / 1000)}s`, |
| 2121 | ); |
| 2122 | sleepMs(waitMs); |
| 2123 | } |
| 2124 | } |
| 2125 | throw lastError; |
| 2126 | } |
| 2127 | |
| 2128 | function ghJson<T>(args: string[]): T { |
| 2129 | return parseGhJson<T>(ghWithRetry(args), args); |
no test coverage detected