Skip to content

bug: could not start new environment error when multiples lambdas are deployed #12636

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
1 task done
gvidasstage opened this issue May 19, 2025 · 3 comments
Open
1 task done
Labels
aws:lambda AWS Lambda type: bug Bug report

Comments

@gvidasstage
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

I'm deploying a couple of lambdas to localstack using nodejs aws cdk. When only a single lambda is deployed, everything works fine. However when I deploy a second one, the first lambda becomes unusable because it fails to start with an error like this

An error occurred (ServiceException) when calling the Invoke operation (reached max retries: 2): [ab187a47-fc9c-48af-801b-51cf9716e147] Internal error while executing lambda localstack-schema-export-test-rest-api:None. Caused by AssignmentException: Could not start new environment: ContainerException:

While the second lambda works fine. Even if I then redeploy using cdk without the second lambda, the first lambda stays unusable until I clear the localstack docker container.

Example cdk:

const app = new App();

class TestStack extends Stack {
  constructor(scope: App) {
    super(scope);

    new nodejs.NodejsFunction(this, 'handler', {
      functionName: `first-lambda`,
      timeout: Duration.seconds(30),
      runtime: lambda.Runtime.NODEJS_22_X,
    });

    new nodejs.NodejsFunction(this, 'handler', {
      functionName: `second-lambda`,
      timeout: Duration.seconds(30),
      runtime: lambda.Runtime.NODEJS_22_X,
    });
  }
}

new TestStack(app, 'TestStack');

Expected Behavior

All deployed lambdas are able to be invoked

How are you starting LocalStack?

With the localstack script

Steps To Reproduce

How are you starting localstack (e.g., bin/localstack command, arguments, or docker-compose.yml)

LOCALSTACK_SERVICES=serverless,sqs,sns,sts,ssm,s3,cloudformation,lambda,iam,apigateway,stepfunctions,events localstack start -d 

Client commands (e.g., AWS SDK code snippet, or sequence of "awslocal" commands)

cdklocal bootstrap --app="npx ts-node path-to-app"
cdklocal deploy --app="npx ts-node path-to-app"

awslocal lambda invoke --function-name first-lambda output.txt

Environment

- OS: macOS 15.5
- LocalStack: 
2025-05-19 09:41:25 LocalStack version: 4.4.1.dev6
2025-05-19 09:41:25 LocalStack build date: 2025-05-12
2025-05-19 09:41:25 LocalStack build git hash: e7383de31

Anything else?

No response

@gvidasstage gvidasstage added type: bug Bug report status: triage needed Requires evaluation by maintainers labels May 19, 2025
@localstack-bot
Copy link
Collaborator

Welcome to LocalStack! Thanks for reporting your first issue and our team will be working towards fixing the issue for you or reach out for more background information. We recommend joining our Slack Community for real-time help and drop a message to LocalStack Support if you are a licensed user! If you are willing to contribute towards fixing this issue, please have a look at our contributing guidelines.

@ryan-berke ryan-berke added area: integration/cdk Issues related to AWS Cloud Development Kit aws:lambda AWS Lambda status: backlog Triaged but not yet being worked on and removed status: triage needed Requires evaluation by maintainers labels May 19, 2025
@joe4dev
Copy link
Member

joe4dev commented May 27, 2025

Hi @gvidasstage

I am unable to reproduce the issue, and we expect multiple Lambda functions to work properly. The following screenshot demonstrates two Lambda functions being invoked simultaneously:
Image

What extra details does debug logging provide using DEBUG=1 localstack start?

Sidenote: Services are loaded lazily, and the SERVICES variable is not required unless you want to configure eager service loading.

@joe4dev joe4dev added status: response required Waiting for a response from the reporter and removed status: backlog Triaged but not yet being worked on area: integration/cdk Issues related to AWS Cloud Development Kit labels May 27, 2025
@gvidasstage
Copy link
Author

I found the issue - one of the lambdas had architecture set to ARM_64, while the other didn't. If I don't set it, or set it to the same architecture for both it works.

@localstack-bot localstack-bot removed the status: response required Waiting for a response from the reporter label May 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aws:lambda AWS Lambda type: bug Bug report
Projects
None yet
Development

No branches or pull requests

4 participants