Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@smythos/sre",
"version": "1.5.51",
"version": "1.5.52",
"description": "Smyth Runtime Environment",
"author": "Alaa-eddine KADDOURI",
"license": "MIT",
Expand Down
5 changes: 4 additions & 1 deletion packages/core/src/helpers/AWSLambdaCode.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,12 @@ export async function createOrUpdateLambdaFunction(functionName, zipFilePath, aw
};

const functionCreateCommand = new CreateFunctionCommand(functionParams);
const functionResponse = await client.send(functionCreateCommand);
await client.send(functionCreateCommand);
// console.log('Function ARN:', functionResponse.FunctionArn);
await verifyFunctionDeploymentStatus(functionName, client);
// wait 500 ms to let the function trust policy be applied
// it will only occur when the function is created for the first time
await new Promise((resolve) => setTimeout(resolve, 500));
Comment on lines +209 to +211
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Replace fixed 500ms sleep with a robust waiter; 500ms is too short and flaky.

Trust-policy/IAM propagation often takes seconds. Fold readiness into the deployment waiter and remove the hard-coded delay.

Apply this diff to remove the brittle sleep:

-            // wait 500 ms to let the function trust policy be applied
-            // it will only occur when the function is created for the first time
-            await new Promise((resolve) => setTimeout(resolve, 500));
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// wait 500 ms to let the function trust policy be applied
// it will only occur when the function is created for the first time
await new Promise((resolve) => setTimeout(resolve, 500));
🤖 Prompt for AI Agents
In packages/core/src/helpers/AWSLambdaCode.helper.ts around lines 209 to 211,
replace the brittle fixed 500ms sleep with a robust waiter: remove the new
Promise setTimeout and instead integrate an AWS-ready waiter that polls for the
function's readiness or the IAM/trust-policy propagation (for example using AWS
SDK's waiter for functionActive or a custom loop with exponential backoff retry
checking GetFunctionConfiguration/GetPolicy until the expected role/trust-policy
is effective), fold this check into the existing deployment waiter flow, set a
sensible timeout (several seconds to minutes) and surface a clear error if the
waiter times out.

}
} catch (error) {
throw error;
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@smythos/sdk",
"version": "1.0.46",
"version": "1.0.47",
"description": "SRE SDK",
"keywords": [
"smythos",
Expand Down