Skip to content

🎥 Make videos programmatically with React

Handle FunctionError's when invoking Lambda

Jonny Burger2a5efed94ccf
diff --git a/packages/lambda/src/functions/launch.ts b/packages/lambda/src/functions/launch.ts
index 50f33e984f..19fe078b0f 100644
--- a/packages/lambda/src/functions/launch.ts
+++ b/packages/lambda/src/functions/launch.ts
@@ -69,13 +69,18 @@ const callFunctionWithRetry = async ({
functionName: string;
}): Promise<unknown> => {
try {
- await getLambdaClient(getCurrentRegionInFunction()).send(
+ const result = await getLambdaClient(getCurrentRegionInFunction()).send(
new InvokeCommand({
FunctionName: process.env.AWS_LAMBDA_FUNCTION_NAME,
Payload: JSON.stringify(payload),
InvocationType: 'Event',
}),
);
+ if (result.FunctionError) {
+ throw new Error(
+ `Lambda function ${functionName} returned an error: ${result.FunctionError} ${result.LogResult}`,
+ );
+ }
} catch (err) {
if ((err as Error).name === 'ResourceConflictException') {
if (retries > 10) {
diff --git a/packages/lambda/src/functions/start.ts b/packages/lambda/src/functions/start.ts
index 4991ae0e40..0dea58b809 100644
--- a/packages/lambda/src/functions/start.ts
+++ b/packages/lambda/src/functions/start.ts
@@ -109,13 +109,19 @@ export const startHandler = async (params: LambdaPayload, options: Options) => {
};
// Don't replace with callLambda(), we want to return before the render is snone
- await getLambdaClient(getCurrentRegionInFunction()).send(
+ const result = await getLambdaClient(getCurrentRegionInFunction()).send(
new InvokeCommand({
FunctionName: process.env.AWS_LAMBDA_FUNCTION_NAME,
Payload: JSON.stringify(payload),
InvocationType: 'Event',
}),
);
+ if (result.FunctionError) {
+ throw new Error(
+ `Lambda function returned error: ${result.FunctionError} ${result.LogResult}`,
+ );
+ }
+
await initialFile;
return {