Skip to content

🎥 Make videos programmatically with React

`@remotion/lambda`: deploySite() does retries and lowers concurrency

Jonny Burger52a2cc917540
diff --git a/packages/lambda/src/api/upload-dir.ts b/packages/lambda/src/api/upload-dir.ts
index a74b0b127d..37cd2fc55a 100644
--- a/packages/lambda/src/api/upload-dir.ts
+++ b/packages/lambda/src/api/upload-dir.ts
@@ -71,7 +71,7 @@ async function getFiles(
return _files.flat(1);
}
-const limit = pLimit(50);
+const limit = pLimit(30);
export const uploadDir = async ({
bucket,
@@ -100,36 +100,55 @@ export const uploadDir = async ({
const client = getS3Client({region, customCredentials: null, forcePathStyle});
+ const uploadWithoutRetry = async (filePath: FileInfo) => {
+ const Key = makeS3Key(keyPrefix, localDir, filePath.name);
+ const Body = createReadStream(filePath.name);
+ const ContentType = mimeTypes.lookup(Key) || 'application/octet-stream';
+ const ACL =
+ privacy === 'no-acl'
+ ? undefined
+ : privacy === 'private'
+ ? 'private'
+ : 'public-read';
+
+ const paralellUploads3 = new Upload({
+ client,
+ queueSize: 4,
+ partSize: 5 * 1024 * 1024,
+ params: {
+ Key,
+ Bucket: bucket,
+ Body,
+ ACL,
+ ContentType,
+ },
+ });
+ paralellUploads3.on('httpUploadProgress', (progress) => {
+ progresses[filePath.name] = progress.loaded ?? 0;
+ });
+ const prom = await paralellUploads3.done();
+ return prom;
+ };
+
+ const uploadWithRetry = async (filePath: FileInfo) => {
+ let error: Error | null = null;
+ for (let i = 0; i < 3; i++) {
+ try {
+ return await uploadWithoutRetry(filePath);
+ } catch (err) {
+ error = err as Error;
+ }
+ }
+
+ if (error) {
+ throw error;
+ }
+ };
+
const uploadAll = (async () => {
const uploads = files.map((filePath) =>
limit(async () => {
- const Key = makeS3Key(keyPrefix, localDir, filePath.name);
- const Body = createReadStream(filePath.name);
- const ContentType = mimeTypes.lookup(Key) || 'application/octet-stream';
- const ACL =
- privacy === 'no-acl'
- ? undefined
- : privacy === 'private'
- ? 'private'
- : 'public-read';
-
- const paralellUploads3 = new Upload({
- client,
- queueSize: 4,
- partSize: 5 * 1024 * 1024,
- params: {
- Key,
- Bucket: bucket,
- Body,
- ACL,
- ContentType,
- },
- });
- paralellUploads3.on('httpUploadProgress', (progress) => {
- progresses[filePath.name] = progress.loaded ?? 0;
- });
- const prom = await paralellUploads3.done();
- return prom;
+ await uploadWithRetry(filePath);
}),
);
await Promise.all(uploads);