Skip to content

🎥 Make videos programmatically with React

`@remotion/lambda`: Fix usage of `getCurrentRegionInFunction()` when using `skipLambdaInvocation: true`

Jonny Burgerb0fe1940ca71
diff --git a/packages/lambda/src/api/get-render-progress.ts b/packages/lambda/src/api/get-render-progress.ts
index f3f5429e64..f27c7552dd 100644
--- a/packages/lambda/src/api/get-render-progress.ts
+++ b/packages/lambda/src/api/get-render-progress.ts
@@ -58,6 +58,7 @@ export const getRenderProgress = async (
providerSpecifics: awsImplementation,
memorySizeInMb: parsed.memorySizeInMb,
timeoutInMilliseconds: parsed.timeoutInSeconds * 1000,
+ functionName: input.functionName,
});
}
diff --git a/packages/lambda/src/functions/helpers/get-current-region.ts b/packages/lambda/src/functions/helpers/get-current-region.ts
index 21defce7ae..78d92f173d 100644
--- a/packages/lambda/src/functions/helpers/get-current-region.ts
+++ b/packages/lambda/src/functions/helpers/get-current-region.ts
@@ -4,7 +4,7 @@ import {isInsideLambda} from '../../shared/is-in-lambda';
export const getCurrentRegionInFunctionImplementation = () => {
if (!isInsideLambda()) {
throw new Error(
- 'Should not call getCurrentRegion() if not inside a lambda function',
+ 'Should not call getCurrentRegionInFunctionImplementation() if not inside a lambda function',
);
}
diff --git a/packages/lambda/src/functions/helpers/get-progress.ts b/packages/lambda/src/functions/helpers/get-progress.ts
index 467d716bda..988c248766 100644
--- a/packages/lambda/src/functions/helpers/get-progress.ts
+++ b/packages/lambda/src/functions/helpers/get-progress.ts
@@ -31,6 +31,7 @@ export const getProgress = async <Provider extends CloudProvider>({
customCredentials,
providerSpecifics,
forcePathStyle,
+ functionName,
}: {
bucketName: string;
renderId: string;
@@ -41,6 +42,7 @@ export const getProgress = async <Provider extends CloudProvider>({
customCredentials: CustomCredentials<Provider> | null;
providerSpecifics: ProviderSpecifics<Provider>;
forcePathStyle: boolean;
+ functionName: string;
}): Promise<GenericRenderProgress<Provider>> => {
const overallProgress = await getOverallProgressS3({
renderId,
@@ -255,7 +257,8 @@ export const getProgress = async <Provider extends CloudProvider>({
renderMetadata,
renderId,
missingChunks: missingChunks ?? [],
- providerSpecifics,
+ region,
+ functionName,
})
: null,
...errorExplanations,
diff --git a/packages/lambda/src/functions/helpers/make-timeout-error.ts b/packages/lambda/src/functions/helpers/make-timeout-error.ts
index d65673c551..2026ddc46c 100644
--- a/packages/lambda/src/functions/helpers/make-timeout-error.ts
+++ b/packages/lambda/src/functions/helpers/make-timeout-error.ts
@@ -1,8 +1,4 @@
-import type {
- CloudProvider,
- EnhancedErrorInfo,
- ProviderSpecifics,
-} from '@remotion/serverless';
+import type {CloudProvider, EnhancedErrorInfo} from '@remotion/serverless';
import type {RenderMetadata} from '@remotion/serverless/client';
import {makeTimeoutMessage} from './make-timeout-message';
@@ -11,20 +7,23 @@ export const makeTimeoutError = <Provider extends CloudProvider>({
missingChunks,
renderMetadata,
renderId,
- providerSpecifics,
+ functionName,
+ region,
}: {
timeoutInMilliseconds: number;
renderMetadata: RenderMetadata<Provider>;
renderId: string;
missingChunks: number[];
- providerSpecifics: ProviderSpecifics<Provider>;
+ functionName: string;
+ region: Provider['region'];
}): EnhancedErrorInfo => {
const message = makeTimeoutMessage({
missingChunks,
renderMetadata,
timeoutInMilliseconds,
renderId,
- providerSpecifics,
+ functionName,
+ region,
});
const error = new Error(message);
diff --git a/packages/lambda/src/functions/helpers/make-timeout-message.ts b/packages/lambda/src/functions/helpers/make-timeout-message.ts
index 46c0de5bc4..7c17cf5ff2 100644
--- a/packages/lambda/src/functions/helpers/make-timeout-message.ts
+++ b/packages/lambda/src/functions/helpers/make-timeout-message.ts
@@ -1,4 +1,4 @@
-import type {CloudProvider, ProviderSpecifics} from '@remotion/serverless';
+import type {CloudProvider} from '@remotion/serverless';
import type {RenderMetadata} from '@remotion/serverless/client';
import {ServerlessRoutines} from '@remotion/serverless/client';
import type {AwsRegion} from '../../regions';
@@ -13,11 +13,11 @@ const MAX_MISSING_CHUNKS = 5;
const makeChunkMissingMessage = <Provider extends CloudProvider>({
missingChunks,
renderMetadata,
- providerSpecifics,
+ region,
}: {
missingChunks: number[];
renderMetadata: RenderMetadata<Provider>;
- providerSpecifics: ProviderSpecifics<Provider>;
+ region: Provider['region'];
}) => {
if (missingChunks.length === 0) {
return 'All chunks have been successfully rendered, but the main function has timed out.';
@@ -45,7 +45,7 @@ const makeChunkMissingMessage = <Provider extends CloudProvider>({
msg,
`â–¸ Logs for chunk ${ch}: ${getCloudwatchRendererUrl({
functionName: process.env.AWS_LAMBDA_FUNCTION_NAME as string,
- region: providerSpecifics.getCurrentRegionInFunction() as AwsRegion,
+ region: region as AwsRegion,
rendererFunctionName: null,
renderId: renderMetadata.renderId,
chunk: ch,
@@ -61,33 +61,38 @@ export const makeTimeoutMessage = <Provider extends CloudProvider>({
missingChunks,
renderMetadata,
renderId,
- providerSpecifics,
+ functionName,
+ region,
}: {
timeoutInMilliseconds: number;
missingChunks: number[];
renderMetadata: RenderMetadata<Provider>;
renderId: string;
- providerSpecifics: ProviderSpecifics<Provider>;
+ region: Provider['region'];
+ functionName: string;
}) => {
const cloudWatchRendererUrl = getCloudwatchRendererUrl({
renderId,
- functionName: process.env.AWS_LAMBDA_FUNCTION_NAME as string,
- region: providerSpecifics.getCurrentRegionInFunction() as AwsRegion,
- rendererFunctionName: process.env.AWS_LAMBDA_FUNCTION_NAME as string,
+ functionName,
+ region: region as AwsRegion,
+ rendererFunctionName: functionName,
chunk: null,
});
const cloudWatchLaunchUrl = getCloudwatchMethodUrl({
renderId,
- functionName: process.env.AWS_LAMBDA_FUNCTION_NAME as string,
+ functionName,
method: ServerlessRoutines.launch,
- region: providerSpecifics.getCurrentRegionInFunction() as AwsRegion,
- rendererFunctionName: process.env.AWS_LAMBDA_FUNCTION_NAME as string,
+ region: region as AwsRegion,
+ rendererFunctionName: functionName,
});
-
const message = [
`The main function timed out after ${timeoutInMilliseconds}ms.`,
- makeChunkMissingMessage({missingChunks, renderMetadata, providerSpecifics}),
+ makeChunkMissingMessage({
+ missingChunks,
+ renderMetadata,
+ region,
+ }),
'',
`Consider increasing the timeout of your function.`,
`â–¸ You can use the "--timeout" parameter when deploying a function via CLI, or the "timeoutInSeconds" parameter when using the deployFunction() API.`,
diff --git a/packages/lambda/src/functions/progress.ts b/packages/lambda/src/functions/progress.ts
index b2ec69067d..c847454603 100644
--- a/packages/lambda/src/functions/progress.ts
+++ b/packages/lambda/src/functions/progress.ts
@@ -43,6 +43,7 @@ export const progressHandler = async <Provider extends CloudProvider>(
customCredentials: lambdaParams.s3OutputProvider ?? null,
providerSpecifics: options.providerSpecifics,
forcePathStyle: lambdaParams.forcePathStyle,
+ functionName: process.env.AWS_LAMBDA_FUNCTION_NAME as string,
});
return progress;
} catch (err) {