( filePath: string, layout: PartLayout, options: UploadArchiveOptions, )
| 123 | } |
| 124 | |
| 125 | async function uploadOnePartWithRetry( |
| 126 | filePath: string, |
| 127 | layout: PartLayout, |
| 128 | options: UploadArchiveOptions, |
| 129 | ): Promise<CompletedUploadPart> { |
| 130 | const maxRetries = Math.max(0, options.maxRetries ?? DEFAULT_MAX_RETRIES); |
| 131 | let lastError: unknown; |
| 132 | for (let attempt = 0; attempt <= maxRetries; attempt += 1) { |
| 133 | try { |
| 134 | return await uploadOnePart(filePath, layout, options); |
| 135 | } catch (error) { |
| 136 | lastError = error; |
| 137 | if (attempt === maxRetries || !isRetryable(error)) break; |
| 138 | await sleep(RETRY_BASE_DELAY_MS * 2 ** attempt); |
| 139 | } |
| 140 | } |
| 141 | throw lastError; |
| 142 | } |
| 143 | |
| 144 | async function uploadOnePart( |
| 145 | filePath: string, |
no test coverage detected