(
mappings: SourceMapMapping[],
request: {
projectId: string;
bucketName: string;
appVersion: string;
options: CommandOptions;
},
)
| 248 | * Orchestrates direct parallel uploads with safe rate limiting concurrency checks and retry actions. |
| 249 | */ |
| 250 | export async function uploadSourceMaps( |
| 251 | mappings: SourceMapMapping[], |
| 252 | request: { |
| 253 | projectId: string; |
| 254 | bucketName: string; |
| 255 | appVersion: string; |
| 256 | options: CommandOptions; |
| 257 | }, |
| 258 | ): Promise<UploadResult> { |
| 259 | const { projectId, bucketName, appVersion, options } = request; |
| 260 | const limit = pLimit(CONCURRENCY); |
| 261 | const results = await Promise.all( |
| 262 | mappings.map((mapping) => |
| 263 | limit(async () => { |
| 264 | const uploadRequest: UploadRequest = { |
| 265 | projectId, |
| 266 | mappingFile: mapping.mapFilePath, |
| 267 | obfuscatedFilePath: mapping.obfuscatedFilePath, |
| 268 | bucketName, |
| 269 | appVersion, |
| 270 | options, |
| 271 | }; |
| 272 | let success = await uploadMap(uploadRequest, 1); |
| 273 | if (!success) { |
| 274 | // Wait 5s and retry |
| 275 | await new Promise((res) => setTimeout(res, options.retryDelay || 5000)); |
| 276 | success = await uploadMap(uploadRequest); |
| 277 | } |
| 278 | return success; |
| 279 | }), |
| 280 | ), |
| 281 | ); |
| 282 | |
| 283 | let successCount = 0; |
| 284 | const failedFiles: string[] = []; |
| 285 | for (const [i, success] of results.entries()) { |
| 286 | if (success) { |
| 287 | successCount++; |
| 288 | } else { |
| 289 | failedFiles.push(mappings[i].mapFilePath); |
| 290 | } |
| 291 | } |
| 292 | |
| 293 | return { |
| 294 | successCount, |
| 295 | failedFiles, |
| 296 | }; |
| 297 | } |
| 298 | |
| 299 | /** |
| 300 | * Prepares zip archive bundle assets and performs file upload tasks to Google Cloud Storage. |
no test coverage detected
searching dependent graphs…