Skip to content

🎥 Make videos programmatically with React

better logging

Jonny Burger9f055ec6184e
diff --git a/packages/example/testlambda.sh b/packages/example/testlambda.sh
new file mode 100644
index 0000000000..be88fe3bdf
--- /dev/null
+++ b/packages/example/testlambda.sh
@@ -0,0 +1,9 @@
+cd ..
+cd lambda
+npm run buildlambda
+cd ..
+cd example
+npx remotion lambda functions rm $(npx remotion lambda functions ls -q) -f
+npx remotion lambda functions deploy
+npm run deploys3
+npm run renderlambda
diff --git a/packages/lambda/remotionlambda.zip b/packages/lambda/remotionlambda.zip
index e419b91eb8..3af52fc2ab 100644
Binary files a/packages/lambda/remotionlambda.zip and b/packages/lambda/remotionlambda.zip differ
diff --git a/packages/lambda/src/cli/commands/render/progress.ts b/packages/lambda/src/cli/commands/render/progress.ts
index 7f356a346f..8444b12117 100644
--- a/packages/lambda/src/cli/commands/render/progress.ts
+++ b/packages/lambda/src/cli/commands/render/progress.ts
@@ -1,6 +1,7 @@
import {CliInternals} from '@remotion/cli';
import {Internals} from 'remotion';
import {CleanupInfo, EncodingProgress, RenderProgress} from '../../../defaults';
+import {EnhancedErrorInfo} from '../../../functions/helpers/write-lambda-error';
type LambdaInvokeProgress = {
totalLambdas: number | null;
@@ -156,16 +157,41 @@ export const makeMultiProgressFromStatus = (
};
};
+const makeErrors = (errors: EnhancedErrorInfo[]) => {
+ if (errors.length === 0) {
+ return null;
+ }
+
+ return errors.map((err) => {
+ const shortStack = `${err.stack.substr(0, 60)}...`;
+ if (err.willRetry) {
+ if (err.chunk === null) {
+ return `Error while preparing render: ${shortStack}... will retry.`;
+ }
+
+ return `Error in chunk ${err.chunk}: ${shortStack}... will retry.`;
+ }
+
+ if (err.chunk === null) {
+ return `Error during preparation: ${shortStack}.`;
+ }
+
+ return `Error in chunk ${err.chunk}: ${shortStack}`;
+ });
+};
+
export const makeProgressString = ({
outName,
progress,
steps,
isDownloaded,
+ errors,
}: {
outName: string | null;
progress: MultiRenderProgress;
steps: number;
isDownloaded: boolean;
+ errors: EnhancedErrorInfo[];
}) => {
return [
makeInvokeProgress(progress.lambdaInvokeProgress, steps),
@@ -174,6 +200,7 @@ export const makeProgressString = ({
invokeProgress: progress.lambdaInvokeProgress,
totalSteps: steps,
}),
+ makeErrors(errors),
makeEncodingProgress({
encodingProgress: progress.encodingProgress,
chunkProgress: progress.chunkProgress,
diff --git a/packages/lambda/src/cli/commands/render/render.ts b/packages/lambda/src/cli/commands/render/render.ts
index ddcabc73f3..9902063039 100644
--- a/packages/lambda/src/cli/commands/render/render.ts
+++ b/packages/lambda/src/cli/commands/render/render.ts
@@ -91,6 +91,7 @@ export const renderCommand = async (args: string[]) => {
makeProgressString({
progress: multiProgress,
outName,
+ errors: status.errors,
steps: totalSteps,
isDownloaded: false,
})
@@ -112,6 +113,7 @@ export const renderCommand = async (args: string[]) => {
progress: newProgress,
steps: totalSteps,
isDownloaded: false,
+ errors: status.errors,
})
);
@@ -123,6 +125,7 @@ export const renderCommand = async (args: string[]) => {
progress: newProgress,
steps: totalSteps,
isDownloaded: false,
+ errors: status.errors,
})
);
if (outName) {
@@ -138,6 +141,7 @@ export const renderCommand = async (args: string[]) => {
progress: newProgress,
steps: totalSteps,
isDownloaded: true,
+ errors: status.errors,
})
);
Log.info();
@@ -157,18 +161,18 @@ export const renderCommand = async (args: string[]) => {
}
if (newStatus.fatalErrorEncountered) {
+ Log.error('\n');
for (const err of newStatus.errors) {
const attemptString = `(Attempt ${err.attempt}/${err.totalAttempts})`;
if (err.chunk === null) {
Log.error('Error occured while preparing video: ' + attemptString);
} else {
- Log.error('Error occurred when rendering chunk ' + err.chunk);
+ Log.error(`Error occurred when rendering chunk ${err.chunk}:`);
}
Log.error(err.stack);
}
- Log.error(JSON.stringify(newStatus.errors));
Log.error('Fatal error encountered. Exiting.');
process.exit(1);
}
diff --git a/packages/lambda/src/functions/helpers/get-progress.ts b/packages/lambda/src/functions/helpers/get-progress.ts
index c6d7157fd6..48ea22ae53 100644
--- a/packages/lambda/src/functions/helpers/get-progress.ts
+++ b/packages/lambda/src/functions/helpers/get-progress.ts
@@ -182,7 +182,9 @@ export const getProgress = async ({
outputFile: outputFile?.url ?? null,
timeToFinish,
errors: errorExplanations,
- fatalErrorEncountered: errorExplanations.some((f) => f.isFatal),
+ fatalErrorEncountered: errorExplanations.some(
+ (f) => f.isFatal && !f.willRetry
+ ),
currentTime: Date.now(),
renderSize,
lambdasInvoked: lambdasInvokedStats.lambdasInvoked,