Skip to content

🎥 Make videos programmatically with React

`@remotion/lambda`: Handle zero renderer invocations

Jonny Burger5f44f565f235
diff --git a/packages/lambda/src/cli/commands/render/progress.ts b/packages/lambda/src/cli/commands/render/progress.ts
index 5fca6ef159..d986896329 100644
--- a/packages/lambda/src/cli/commands/render/progress.ts
+++ b/packages/lambda/src/cli/commands/render/progress.ts
@@ -45,17 +45,24 @@ const makeInvokeProgress = (overall: RenderProgress) => {
overall.renderMetadata?.estimatedRenderLambdaInvokations ?? null,
};
const {lambdasInvoked, totalLambdas} = invokeProgress;
- const progress = totalLambdas === null ? 0 : lambdasInvoked / totalLambdas;
+ const progress =
+ totalLambdas === null
+ ? 0
+ : totalLambdas === 0
+ ? 1
+ : lambdasInvoked / totalLambdas;
const topLine = [
- `${progress === 0 ? 'Invoked' : 'Invoking'} lambdas`.padEnd(
+ `${totalLambdas === 0 || progress === 0 ? 'Invoked' : 'Invoking'} lambdas`.padEnd(
CliInternals.LABEL_WIDTH,
),
CliInternals.makeProgressBar(progress, false),
- progress === 1
- ? CliInternals.chalk.gray(`${lambdasInvoked}/${totalLambdas}`)
- : totalLambdas === null
- ? null
- : `${lambdasInvoked}/${totalLambdas}`,
+ totalLambdas === 0
+ ? null
+ : progress === 1
+ ? CliInternals.chalk.gray(`${lambdasInvoked}/${totalLambdas}`)
+ : totalLambdas === null
+ ? null
+ : `${lambdasInvoked}/${totalLambdas}`,
].join(' ');
return [
diff --git a/packages/lambda/src/test/integration/renders/muted-render.test.ts b/packages/lambda/src/test/integration/renders/muted-render.test.ts
index f4b08de97b..470817295b 100644
--- a/packages/lambda/src/test/integration/renders/muted-render.test.ts
+++ b/packages/lambda/src/test/integration/renders/muted-render.test.ts
@@ -5,6 +5,7 @@ import path from 'path';
import {LambdaClientInternals} from '@remotion/lambda-client';
import {RenderInternals, getVideoMetadata} from '@remotion/renderer';
import {rendersPrefix, ServerlessRoutines} from '@remotion/serverless';
+import {makeProgressString} from '../../../cli/commands/render/progress';
import {mockImplementation} from '../../mocks/mock-implementation';
import {getMockInvocationTypesForRender} from '../../mocks/mock-invocations';
import {simulateLambdaRender} from '../simulate-lambda-render';
@@ -47,6 +48,12 @@ test('Should directly make a muted render with one Lambda', async () => {
]);
expect(progress.renderMetadata?.estimatedTotalLambdaInvokations).toBe(1);
expect(progress.renderMetadata?.estimatedRenderLambdaInvokations).toBe(0);
+ const progressString = makeProgressString({
+ downloadInfo: null,
+ overall: progress,
+ });
+ expect(progressString).toContain('Invoked lambdas');
+ expect(progressString).not.toContain('1/0');
unlinkSync(tmpfile);
diff --git a/packages/serverless/src/render-with-single-function.ts b/packages/serverless/src/render-with-single-function.ts
index 2992080a4e..98ade45a4e 100644
--- a/packages/serverless/src/render-with-single-function.ts
+++ b/packages/serverless/src/render-with-single-function.ts
@@ -56,7 +56,6 @@ export const renderWithSingleFunction = async <Provider extends CloudProvider>({
},
onStream: (message) => {
if (message.type === 'lambda-invoked') {
- overallProgress.setLambdaInvoked(payload.chunk);
return Promise.resolve();
}