Skip to content

🎥 Make videos programmatically with React

`@remotion/lambda`: Better error handling of new error `ConcurrentInvocationLimitExceeded`

Jonny Burger4f33a37d1ae9
diff --git a/packages/docs/docs/lambda/troubleshooting/rate-limit.mdx b/packages/docs/docs/lambda/troubleshooting/rate-limit.mdx
index e3a7b3c5d5..e4f300c684 100644
--- a/packages/docs/docs/lambda/troubleshooting/rate-limit.mdx
+++ b/packages/docs/docs/lambda/troubleshooting/rate-limit.mdx
@@ -1,7 +1,7 @@
---
image: /generated/articles-docs-lambda-troubleshooting-rate-limit.png
id: rate-limit
-sidebar_label: TooManyRequestsException
+sidebar_label: ConcurrentInvocationLimitExceeded
title: AWS Rate Limit Troubleshooting
crumb: 'Lambda Troubleshooting'
---
@@ -12,6 +12,12 @@ If you get an error message:
TooManyRequestsException: Rate Exceeded.
```
+or
+
+```
+ConcurrentInvocationLimitExceeded
+```
+
while calling a Lambda function, it means your concurrency limit has been reached.
- **Concurrency limit**: The maximum amount of Lambda functions that can run concurrently per region per account.
diff --git a/packages/lambda-client/src/call-lambda-streaming.ts b/packages/lambda-client/src/call-lambda-streaming.ts
index 36475d27e6..af1f430c83 100644
--- a/packages/lambda-client/src/call-lambda-streaming.ts
+++ b/packages/lambda-client/src/call-lambda-streaming.ts
@@ -192,7 +192,10 @@ export const callFunctionWithStreamingImplementation = async <
// Do not remove this await
await callLambdaWithStreamingWithoutRetry<T, Provider>(options);
} catch (err) {
- if ((err as Error).stack?.includes('TooManyRequestsException')) {
+ if (
+ (err as Error).stack?.includes('TooManyRequestsException') ||
+ (err as Error).message?.includes('ConcurrentInvocationLimitExceeded')
+ ) {
throw new Error(
`AWS Concurrency limit reached (Original Error: ${(err as Error).message}). See https://www.remotion.dev/docs/lambda/troubleshooting/rate-limit for tips to fix this.`,
);
diff --git a/packages/lambda/src/cli/index.ts b/packages/lambda/src/cli/index.ts
index f3807da73a..072f5a0664 100644
--- a/packages/lambda/src/cli/index.ts
+++ b/packages/lambda/src/cli/index.ts
@@ -240,6 +240,15 @@ AWS returned an "TooManyRequestsException" error message which could mean you re
);
}
+ if (error.stack?.includes('ConcurrentInvocationLimitExceeded')) {
+ Log.error(
+ {indent: false, logLevel},
+ `
+AWS returned an "ConcurrentInvocationLimitExceeded" error message which could mean you reached the concurrency limit of AWS Lambda. You can increase the limit - read this troubleshooting page: ${DOCS_URL}/docs/lambda/troubleshooting/rate-limit. The original error message is:
+`.trim(),
+ );
+ }
+
if (
error.stack?.includes(
'The security token included in the request is invalid',
diff --git a/packages/renderer/src/print-useful-error-message.ts b/packages/renderer/src/print-useful-error-message.ts
index 5a15ef0f82..ae6e0b2bfe 100644
--- a/packages/renderer/src/print-useful-error-message.ts
+++ b/packages/renderer/src/print-useful-error-message.ts
@@ -94,7 +94,10 @@ export const printUsefulErrorMessage = (
);
}
- if (err.stack?.includes('TooManyRequestsException: Rate Exceeded.')) {
+ if (
+ err.stack?.includes('TooManyRequestsException: Rate Exceeded.') ||
+ err.message?.includes('ConcurrentInvocationLimitExceeded')
+ ) {
Log.info({indent, logLevel});
Log.info(
{indent, logLevel},
diff --git a/packages/serverless-client/src/inspect-error.ts b/packages/serverless-client/src/inspect-error.ts
index a3d2947163..f6b13fd1f9 100644
--- a/packages/serverless-client/src/inspect-error.ts
+++ b/packages/serverless-client/src/inspect-error.ts
@@ -26,7 +26,10 @@ const getExplanation = (stack: string) => {
);
}
- if (stack.includes('TooManyRequestsException')) {
+ if (
+ stack.includes('TooManyRequestsException') ||
+ stack.includes('ConcurrentInvocationLimitExceeded')
+ ) {
return `AWS returned an "TooManyRequestsException" error message which could mean you reached the concurrency limit of AWS Lambda. You can increase the limit - read this troubleshooting page: ${DOCS_URL}/docs/lambda/troubleshooting/rate-limit`;
}