Skip to content

🎥 Make videos programmatically with React

renderer function

Jonny Burger62e5db649c43
diff --git a/packages/lambda/src/functions/helpers/make-timeout-error.ts b/packages/lambda/src/functions/helpers/make-timeout-error.ts
index 38785014c9..4aaa485ade 100644
--- a/packages/lambda/src/functions/helpers/make-timeout-error.ts
+++ b/packages/lambda/src/functions/helpers/make-timeout-error.ts
@@ -8,10 +8,12 @@ export const makeTimeoutError = ({
timeoutInMilliseconds,
chunks,
renderMetadata,
+ renderId,
}: {
timeoutInMilliseconds: number;
chunks: _Object[];
renderMetadata: RenderMetadata;
+ renderId: string;
}): EnhancedErrorInfo => {
const availableChunks = chunks.map((c) =>
parseLambdaChunkKey(c.Key as string)
@@ -28,6 +30,7 @@ export const makeTimeoutError = ({
missingChunks,
renderMetadata,
timeoutInMilliseconds,
+ renderId,
});
return {
diff --git a/packages/lambda/src/functions/helpers/make-timeout-message.ts b/packages/lambda/src/functions/helpers/make-timeout-message.ts
index 6760b05de8..5b1b1321d7 100644
--- a/packages/lambda/src/functions/helpers/make-timeout-message.ts
+++ b/packages/lambda/src/functions/helpers/make-timeout-message.ts
@@ -1,5 +1,7 @@
-import type {RenderMetadata} from '../../defaults';
+import {LambdaRoutines, type RenderMetadata} from '../../defaults';
import {DOCS_URL} from '../../shared/docs-url';
+import { getCloudwatchStreamUrl } from '../../shared/get-aws-urls';
+import { getCurrentRegionInFunction } from './get-current-region';
const makeChunkMissingMessage = ({
missingChunks,
@@ -33,18 +35,41 @@ export const makeTimeoutMessage = ({
timeoutInMilliseconds,
missingChunks,
renderMetadata,
+ renderId,
}: {
timeoutInMilliseconds: number;
missingChunks: number[];
renderMetadata: RenderMetadata;
+ renderId: string;
}) => {
+
+ const cloudWatchRendererUrl = getCloudwatchStreamUrl({
+ renderId,
+ functionName: process.env.AWS_LAMBDA_FUNCTION_NAME as string,
+ method: LambdaRoutines.renderer,
+ region: getCurrentRegionInFunction(),
+ rendererFunctionName: process.env.AWS_LAMBDA_FUNCTION_NAME as string
+ })
+
+ const cloudWatchLaunchUrl = getCloudwatchStreamUrl({
+ renderId,
+ functionName: process.env.AWS_LAMBDA_FUNCTION_NAME as string,
+ method: LambdaRoutines.launch,
+ region: getCurrentRegionInFunction(),
+ rendererFunctionName: process.env.AWS_LAMBDA_FUNCTION_NAME as string
+ })
+
const message = [
`The main function timed out after ${timeoutInMilliseconds}ms.`,
`Consider increasing the timeout of your function.`,
makeChunkMissingMessage({missingChunks, renderMetadata}),
- `You can use the "--timeout" parameter when deploying a function via CLI, or the "timeoutInSeconds" parameter when using the deployFunction() API.`,
+ `â–¸ You can use the "--timeout" parameter when deploying a function via CLI, or the "timeoutInSeconds" parameter when using the deployFunction() API.`,
`${DOCS_URL}/docs/lambda/cli/functions#deploy`,
- 'Get help on debugging this error:',
+ 'â–¸ Visit the logs for the main function:',
+ cloudWatchLaunchUrl,
+ 'â–¸ Visit the logs for the renderer functions:',
+ cloudWatchRendererUrl,
+ 'â–¸ Get help on debugging this error:',
`${DOCS_URL}/docs/lambda/troubleshooting/debug`,
].join('\n');
diff --git a/packages/lambda/src/functions/renderer.ts b/packages/lambda/src/functions/renderer.ts
index 89e50c95fe..88e928b22d 100644
--- a/packages/lambda/src/functions/renderer.ts
+++ b/packages/lambda/src/functions/renderer.ts
@@ -3,6 +3,7 @@ import {RenderInternals} from '@remotion/renderer';
import fs from 'node:fs';
import path from 'node:path';
import {VERSION} from 'remotion/version';
+import {Log} from '../cli/log';
import {callLambda} from '../shared/call-lambda';
import {writeLambdaInitializedFile} from '../shared/chunk-progress';
import {decompressInputProps} from '../shared/compress-props';
@@ -249,6 +250,8 @@ const renderHandler = async (
timings: Object.values(chunkTimingData.timings),
};
+ Log.verbose('Writing chunk to S3');
+ const writeStart = Date.now();
await lambdaWriteFile({
bucketName: params.bucketName,
key: chunkKeyForIndex({
@@ -262,6 +265,8 @@ const renderHandler = async (
downloadBehavior: null,
customCredentials: null,
});
+ Log.verbose('Wrote chunk to S3', {time: Date.now() - writeStart});
+ Log.verbose('Cleaning up and writing timings');
await Promise.all([
fs.promises.rm(outputLocation, {recursive: true}),
fs.promises.rm(outputPath, {recursive: true}),