Upload Cloudflare files in parallel

This commit is contained in:
Alex Gleason committed 2025-12-03 23:11:15 -06:00
1 parent 74b5f60df8
commit ff6932ecda
1 file changed
+12 -11
+12 -11
View File
@@ -88,7 +88,7 @@ export class CloudflareAdapter implements DeployAdapter {
// Step 2: Initialize upload session // Step 2: Initialize upload session
const initResponse = await this.initializeUploadSession(scriptName, manifest); const initResponse = await this.initializeUploadSession(scriptName, manifest);
// Step 3: Upload files in buckets // Step 3: Upload files in buckets (in parallel for speed)
let completionJwt = initResponse.jwt; let completionJwt = initResponse.jwt;
if (initResponse.buckets.flat().length > 0) { if (initResponse.buckets.flat().length > 0) {
@@ -98,16 +98,17 @@ export class CloudflareAdapter implements DeployAdapter {
hashToFile.set(fileInfo.hash, { path: filePath, info: fileInfo }); hashToFile.set(fileInfo.hash, { path: filePath, info: fileInfo });
} }
// Upload each bucket // Upload all buckets in parallel
for (const bucket of initResponse.buckets) { const uploadResults = await Promise.all(
const uploadResult = await this.uploadBucket( initResponse.buckets.map((bucket) =>
initResponse.jwt, this.uploadBucket(initResponse.jwt, bucket, hashToFile)
bucket, )
hashToFile );
);
if (uploadResult.jwt) { // Get the completion JWT from the last result that has one
completionJwt = uploadResult.jwt; const lastJwtResult = [...uploadResults].reverse().find((r) => r.jwt);
} if (lastJwtResult?.jwt) {
completionJwt = lastJwtResult.jwt;
} }
} }