Skip to content

The open alternative to Salesforce, designed for AI.

fix(server): pace lambda control-plane calls to avoid 'Rate exceeded' on release (#22569)

Thomas Trompettefb0a54c73aac
diff --git a/packages/twenty-server/src/engine/core-modules/logic-function/logic-function-drivers/drivers/lambda/constants/lambda-driver.constant.ts b/packages/twenty-server/src/engine/core-modules/logic-function/logic-function-drivers/drivers/lambda/constants/lambda-driver.constant.ts
index e479414f00e..3a959956125 100644
--- a/packages/twenty-server/src/engine/core-modules/logic-function/logic-function-drivers/drivers/lambda/constants/lambda-driver.constant.ts
+++ b/packages/twenty-server/src/engine/core-modules/logic-function/logic-function-drivers/drivers/lambda/constants/lambda-driver.constant.ts
@@ -5,6 +5,9 @@ import { ASSET_PATH } from 'src/constants/assets-path';
export const UPDATE_FUNCTION_DURATION_TIMEOUT_IN_SECONDS = 60;
export const CREDENTIALS_DURATION_IN_SECONDS = 60 * 60; // 1h
+export const LAMBDA_CLIENT_MAX_ATTEMPTS = 8;
+export const LAMBDA_CLIENT_RETRY_MODE = 'adaptive' as const;
+
export const YARN_INSTALL_LAMBDA_TIMEOUT_SECONDS = 300;
export const YARN_INSTALL_LAMBDA_MEMORY_MB = 1024;
export const BUILDER_LAMBDA_TIMEOUT_SECONDS = 60;
diff --git a/packages/twenty-server/src/engine/core-modules/logic-function/logic-function-drivers/drivers/lambda/services/lambda-aws-client.service.ts b/packages/twenty-server/src/engine/core-modules/logic-function/logic-function-drivers/drivers/lambda/services/lambda-aws-client.service.ts
index 009b6174ad1..f95f23247f1 100644
--- a/packages/twenty-server/src/engine/core-modules/logic-function/logic-function-drivers/drivers/lambda/services/lambda-aws-client.service.ts
+++ b/packages/twenty-server/src/engine/core-modules/logic-function/logic-function-drivers/drivers/lambda/services/lambda-aws-client.service.ts
@@ -11,6 +11,8 @@ import { isDefined } from 'twenty-shared/utils';
import {
CREDENTIALS_DURATION_IN_SECONDS,
+ LAMBDA_CLIENT_MAX_ATTEMPTS,
+ LAMBDA_CLIENT_RETRY_MODE,
UPDATE_FUNCTION_DURATION_TIMEOUT_IN_SECONDS,
} from 'src/engine/core-modules/logic-function/logic-function-drivers/drivers/lambda/constants/lambda-driver.constant';
import { type LambdaDriverOptions } from 'src/engine/core-modules/logic-function/logic-function-drivers/drivers/lambda/types/lambda-driver.type';
@@ -35,6 +37,8 @@ export class LambdaAwsClientService {
...(isDefined(this.options.subhostingRole) && {
credentials: await this.getAssumeRoleCredentials(),
}),
+ maxAttempts: LAMBDA_CLIENT_MAX_ATTEMPTS,
+ retryMode: LAMBDA_CLIENT_RETRY_MODE,
});
}