Skip to content

🎥 Make videos programmatically with React

max retries

Jonny Burger3285ca2df34d
diff --git a/packages/docs/docs/lambda-changelog.md b/packages/docs/docs/lambda-changelog.md
index f2d09df9f3..589e6be032 100644
--- a/packages/docs/docs/lambda-changelog.md
+++ b/packages/docs/docs/lambda-changelog.md
@@ -14,6 +14,10 @@ Keep track of changes to the APIs of Remotion Lambda here.
1. Redeploy your function: `npx remotion lambda functions deploy`
1. Migrate according to the changelog below:
+## Unreleased
+
+- The default number of max retries is now 1 (previously 3). A new CLI flag `--max-retries` was introduced which can be used for `npx remotion lambda render` and `npx remotion lambda still`
+
## November 12th, 2021
Version hash: `3.0.0-lambda.99+bd5d55651`
diff --git a/packages/docs/docs/lambda-setup.md b/packages/docs/docs/lambda-setup.md
index d3fb03125d..86decb4af4 100644
--- a/packages/docs/docs/lambda-setup.md
+++ b/packages/docs/docs/lambda-setup.md
@@ -258,7 +258,7 @@ const { renderId, bucketName } = await renderVideoOnLambda({
inputProps: {},
codec: "h264-mkv",
imageFormat: "jpeg",
- maxRetries: 3,
+ maxRetries: 1,
framesPerLambda: 20,
privacy: "public",
});
@@ -291,7 +291,7 @@ const { renderId, bucketName } = await renderVideoOnLambda({
inputProps: {},
codec: "h264-mkv",
imageFormat: "jpeg",
- maxRetries: 3,
+ maxRetries: 1,
framesPerLambda: 20,
privacy: "public",
});
diff --git a/packages/docs/docs/renderstillonlambda.md b/packages/docs/docs/renderstillonlambda.md
index 5be221747b..804cff96b1 100644
--- a/packages/docs/docs/renderstillonlambda.md
+++ b/packages/docs/docs/renderstillonlambda.md
@@ -26,7 +26,7 @@ const { estimatedPrice, url, size } = await renderStillOnLambda({
composition: "MyVideo",
inputProps: {},
imageFormat: "png",
- maxRetries: 3,
+ maxRetries: 1,
privacy: "public",
envVariables: {},
frame: 10,
@@ -84,7 +84,7 @@ Only applies if `imageFormat` is `"jpeg"`, otherwise this option is invalid.
### `maxRetries?`
-_optional - default `3`_
+_optional - default `1`_
How often a frame render may be retried until it fails.
diff --git a/packages/docs/docs/rendervideoonlambda.md b/packages/docs/docs/rendervideoonlambda.md
index ce612ee17c..bf3277749f 100644
--- a/packages/docs/docs/rendervideoonlambda.md
+++ b/packages/docs/docs/rendervideoonlambda.md
@@ -26,7 +26,7 @@ const { bucketName, renderId } = await renderVideoOnLambda({
inputProps: {},
codec: "h264-mkv",
imageFormat: "jpeg",
- maxRetries: 3,
+ maxRetries: 1,
privacy: "public",
enableChunkOptimization: true,
});
@@ -102,6 +102,8 @@ See [`renderFrames() -> quality`](/docs/render-frames#quality).
### `maxRetries`
+_optional, default `1`_
+
How often a chunk may be retried to render in case the render fails.
If a rendering of a chunk is failed, the error will be reported in the [`getRenderProgress()`](/docs/lambda/getrenderprogress) object and retried up to as many times as you specify using this option.
diff --git a/packages/lambda/src/api/render-still-on-lambda.ts b/packages/lambda/src/api/render-still-on-lambda.ts
index 774eedbbfb..2c867dfc2c 100644
--- a/packages/lambda/src/api/render-still-on-lambda.ts
+++ b/packages/lambda/src/api/render-still-on-lambda.ts
@@ -1,7 +1,7 @@
import {StillImageFormat} from 'remotion';
import {AwsRegion} from '../pricing/aws-regions';
import {callLambda} from '../shared/call-lambda';
-import {LambdaRoutines} from '../shared/constants';
+import {DEFAULT_MAX_RETRIES, LambdaRoutines} from '../shared/constants';
/**
* @description Renders a still frame on Lambda
* @link https://remotion-lambda-alpha.netlify.app/docs/lambda/renderstillonlambda
@@ -56,7 +56,7 @@ export const renderStillOnLambda = async ({
imageFormat,
envVariables,
quality,
- maxRetries: maxRetries ?? 3,
+ maxRetries: maxRetries ?? DEFAULT_MAX_RETRIES,
frame: frame ?? 0,
privacy,
attempt: 1,
diff --git a/packages/lambda/src/cli/args.ts b/packages/lambda/src/cli/args.ts
index d85efb8cdf..5c66921cfd 100644
--- a/packages/lambda/src/cli/args.ts
+++ b/packages/lambda/src/cli/args.ts
@@ -17,6 +17,7 @@ type LambdaCommandLineOptions = {
['disable-chunk-optimization']: boolean;
['save-browser-logs']: boolean;
['disable-cloudwatch']: boolean;
+ ['max-retries']: number;
};
export const parsedLambdaCli = minimist<LambdaCommandLineOptions>(
diff --git a/packages/lambda/src/cli/commands/still.ts b/packages/lambda/src/cli/commands/still.ts
index f732518c3b..db1bcb39e0 100644
--- a/packages/lambda/src/cli/commands/still.ts
+++ b/packages/lambda/src/cli/commands/still.ts
@@ -1,7 +1,7 @@
import {CliInternals} from '@remotion/cli';
import {StillImageFormat} from 'remotion';
import {renderStillOnLambda} from '../../api/render-still-on-lambda';
-import {BINARY_NAME} from '../../shared/constants';
+import {BINARY_NAME, DEFAULT_MAX_RETRIES} from '../../shared/constants';
import {parsedLambdaCli} from '../args';
import {getAwsRegion} from '../get-aws-region';
import {findFunctionName} from '../helpers/find-function-name';
@@ -39,6 +39,11 @@ export const stillCommand = async (args: string[]) => {
const functionName = await findFunctionName();
+ const maxRetries = parsedLambdaCli['max-retries'] ?? DEFAULT_MAX_RETRIES;
+ if (typeof maxRetries !== 'number') {
+ throw new TypeError('max retries should be a number, but is ' + maxRetries);
+ }
+
const res = await renderStillOnLambda({
functionName,
serveUrl,
@@ -48,8 +53,7 @@ export const stillCommand = async (args: string[]) => {
// TODO: Make configurable
privacy: 'public',
region: getAwsRegion(),
- // TODO: Unhardcdoe retries
- maxRetries: 3,
+ maxRetries,
envVariables: cliOptions.envVariables,
frame: cliOptions.stillFrame,
quality: cliOptions.quality,
diff --git a/packages/lambda/src/shared/constants.ts b/packages/lambda/src/shared/constants.ts
index 62f774311f..6fed4def2e 100644
--- a/packages/lambda/src/shared/constants.ts
+++ b/packages/lambda/src/shared/constants.ts
@@ -24,6 +24,7 @@ export const DEFAULT_FRAMES_PER_LAMBDA = 20;
export const BINARY_NAME = 'remotion lambda';
export const COMMAND_NOT_FOUND = 'Command not found';
export const DEFAULT_REGION: AwsRegion = 'us-east-1';
+export const DEFAULT_MAX_RETRIES = 1;
export const DEFAULT_CLOUDWATCH_RETENTION_PERIOD = 14;