Skip to content

Bug: Invoke failed error=ErrAgentNameCollision #7123

@exodus-justinz

Description

@exodus-justinz

Description:

sam local invoke fails with the following error Invoke failed error=ErrAgentNameCollision when using Cloudwatch Synthetic lambda layer, but works fine without it.

Steps to reproduce:

Run sam build then sam local invoke with the following files

index.js

exports.handler = async (event, context) => {
  console.log("Success");
};

template.yaml

AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Description: Sample SAM Template for testing Synthetics NodeJS canary locally

Resources:
  Function:
    Type: AWS::Serverless::Function
    Properties:
      Description: Local Synthetics NodeJS Dev Canary
      Handler: index.handler
      Runtime: nodejs18.x
      Layers:
        - arn:aws:lambda:us-east-1:378653112637:layer:Synthetics:44

Observed result:

> sam local invoke --debug
2024-06-03 10:52:35,246 | No config file found in this directory.                                                                                                    
2024-06-03 10:52:35,248 | OSError occurred while reading TOML file: [Errno 2] No such file or directory: '/Users/<USER>/github/node-test/samconfig.toml'           
2024-06-03 10:52:35,249 | Config file location: /Users/<USER>/github/node-test/samconfig.toml                                                                      
2024-06-03 10:52:35,249 | Config file '/Users/<USER>/github/node-test/samconfig.toml' does not exist                                                               
2024-06-03 10:52:35,250 | Using SAM Template at /Users/<USER>/github/node-test/.aws-sam/build/template.yaml                                                        
2024-06-03 10:52:35,267 | OSError occurred while reading TOML file: [Errno 2] No such file or directory: '/Users/<USER>/github/node-test/samconfig.toml'           
2024-06-03 10:52:35,268 | Using config file: samconfig.toml, config environment: default                                                                             
2024-06-03 10:52:35,268 | Expand command line arguments to:                                                                                                          
2024-06-03 10:52:35,268 | --template_file=/Users/<USER>/github/node-test/.aws-sam/build/template.yaml --no_event                                                   
--layer_cache_basedir=/Users/<USER>/.aws-sam/layers-pkg --container_host=localhost --container_host_interface=127.0.0.1                                            
2024-06-03 10:52:35,269 | local invoke command is called                                                                                                             
2024-06-03 10:52:35,270 | No Parameters detected in the template                                                                                                     
2024-06-03 10:52:35,282 | Sam customer defined id is more priority than other IDs. Customer defined id for resource Function is Function                             
2024-06-03 10:52:35,282 | 0 stacks found in the template                                                                                                             
2024-06-03 10:52:35,283 | No Parameters detected in the template                                                                                                     
2024-06-03 10:52:35,291 | Sam customer defined id is more priority than other IDs. Customer defined id for resource Function is Function                             
2024-06-03 10:52:35,291 | 1 resources found in the stack                                                                                                             
2024-06-03 10:52:35,292 | Found Serverless function with name='Function' and CodeUri='Function'                                                                      
2024-06-03 10:52:35,292 | --base-dir is not presented, adjusting uri Function relative to /Users/<USER>/github/node-test/.aws-sam/build/template.yaml              
2024-06-03 10:52:35,302 | Found one Lambda function with name 'Function'                                                                                             
2024-06-03 10:52:35,302 | Invoking index.handler (nodejs18.x)                                                                                                        
2024-06-03 10:52:35,303 | No environment variables found for function 'Function'                                                                                     
2024-06-03 10:52:35,303 | Loading AWS credentials from session with profile 'None'                                                                                   
2024-06-03 10:52:37,319 | Resolving code path. Cwd=/Users/<USER>/github/node-test/.aws-sam/build, CodeUri=/Users/<USER>/github/node-test/.aws-sam/build/Function 
2024-06-03 10:52:37,320 | Resolved absolute path to code is /Users/<USER>/github/node-test/.aws-sam/build/Function                                                 
2024-06-03 10:52:37,321 | Resolving code path. Cwd=/Users/<USER>/github/node-test/.aws-sam/build, CodeUri=/Users/<USER>/github/node-test/.aws-sam/build/Function 
2024-06-03 10:52:37,321 | Resolved real code path to /Users/<USER>/github/node-test/.aws-sam/build/Function                                                        
2024-06-03 10:52:37,322 | Code /Users/<USER>/github/node-test/.aws-sam/build/Function is not a zip/jar file                                                        
2024-06-03 10:52:37,322 | arn:aws:lambda:us-east-1:378653112637:layer:Synthetics:44 is already cached. Skipping download                                             
2024-06-03 10:52:41,510 | Local image is up-to-date                                                                                                                  
2024-06-03 10:52:41,535 | Checking free port on 127.0.0.1:8346                                                                                                       
2024-06-03 10:52:41,547 | Using local image: samcli/lambda-nodejs:18-x86_64-f71ec5643fe0df391046c2029.                                                               
                                                                                                                                                                     
2024-06-03 10:52:41,548 | Mounting /Users/<USER>/github/node-test/.aws-sam/build/Function as /var/task:ro,delegated, inside runtime container                      
2024-06-03 10:52:41,821 | Starting a timer for 3 seconds for function 'Function'                                                                                     
2024-06-03 10:52:41,824 | Getting lock for the key localhost-8346                                                                                                    
2024-06-03 10:52:41,826 | Waiting to retrieve the lock (localhost-8346) to start invocation                                                                          
START RequestId: 1acade56-67bd-4275-bccc-6eb08a6a7e0e Version: $LATEST
03 Jun 2024 02:52:41,965 [ERROR] (rapid) Init failed error=signal: segmentation fault InvokeID=
03 Jun 2024 02:52:41,969 [ERROR] (rapid) Invoke failed error=ErrAgentNameCollision InvokeID=c969ec12-b3a9-44ec-9c74-b0365b2d1212
03 Jun 2024 02:52:41,971 [ERROR] (rapid) Invoke DONE failed: Sandbox.Failure
2024-06-03 10:52:41,974 | Failed to deserialize response from RIE, returning the raw response as is                                                                  

2024-06-03 10:52:42,988 | [Container state] OOMKilled False                                                                                                          
2024-06-03 10:52:43,106 | Cleaning all decompressed code dirs                                                                                                        
2024-06-03 10:52:43,107 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics                                 
2024-06-03 10:52:43,172 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics                                 
2024-06-03 10:52:43,173 | Sending Telemetry: {'metrics': [{'commandRun': {'requestId': 'f8499d24-991b-41e5-a3c6-43cfd2a4ea63', 'installationId':                     
'ce33ef12-8739-473b-8579-37f993e80fae', 'sessionId': 'e03186b6-3442-424c-b1bf-f574d1eb33a5', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.12.3',      
'samcliVersion': '1.116.0', 'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '', 'commandName': 'sam local invoke', 'metricSpecificAttributes':     
{'projectType': 'CFN', 'gitOrigin': None, 'projectName': 'ae9f89a5516b52de1ce5b3595bf68531c9737250c891d8f618e517db18487386', 'initialCommit': None}, 'duration':     
7839, 'exitReason': 'success', 'exitCode': 0}}]}                                                                                                                     
2024-06-03 10:52:43,173 | Unable to find Click Context for getting session_id.                                                                                       
2024-06-03 10:52:43,177 | Sending Telemetry: {'metrics': [{'events': {'requestId': '48844173-9b5e-48f4-8b5f-3d667ec8a021', 'installationId':                         
'ce33ef12-8739-473b-8579-37f993e80fae', 'sessionId': 'e03186b6-3442-424c-b1bf-f574d1eb33a5', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.12.3',      
'samcliVersion': '1.116.0', 'commandName': 'sam local invoke', 'metricSpecificAttributes': {'events': [{'event_name': 'SamConfigFileExtension', 'event_value':       
'.toml', 'thread_id': 'c3b2bcdafa85498fb06726c5b1535eef', 'time_stamp': '2024-06-03 02:52:35.248', 'exception_name': None}, {'event_name': 'SamConfigFileExtension', 
'event_value': '.toml', 'thread_id': 'a373f5c179504c6583cbd7a293fb38d8', 'time_stamp': '2024-06-03 02:52:35.268', 'exception_name': None}]}}}]}                      
2024-06-03 10:52:43,907 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)           
2024-06-03 10:52:43,913 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)           
2024-06-03 10:52:43,915 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics                                 
2024-06-03 10:52:43,916 | Sending Telemetry: {'metrics': [{'runtimeMetric': {'requestId': 'b6527113-a8ba-4362-9b36-55ce5dc422ef', 'installationId':                  
'ce33ef12-8739-473b-8579-37f993e80fae', 'sessionId': 'e03186b6-3442-424c-b1bf-f574d1eb33a5', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.12.3',      
'samcliVersion': '1.116.0', 'runtimes': ['nodejs18.x']}}]}                                                                                                           
2024-06-03 10:52:44,419 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)   

Expected result:

> sam local invoke
Invoking index.handler (nodejs18.x)                                                                                                                                  
Local image is up-to-date                                                                                                                                            
Using local image: public.ecr.aws/lambda/nodejs:18-rapid-x86_64.                                                                                                     
                                                                                                                                                                     
Mounting /Users/<USER>/github/node-test/.aws-sam/build/Function as /var/task:ro,delegated, inside runtime container                                                
START RequestId: d6129caa-891d-4702-a75d-dcb1f16a3a87 Version: $LATEST
2024-06-03T02:55:34.246Z        08f97fda-1155-4e35-be11-0658da88d6e0    INFO    Success
END RequestId: 08f97fda-1155-4e35-be11-0658da88d6e0
REPORT RequestId: 08f97fda-1155-4e35-be11-0658da88d6e0  Init Duration: 0.35 ms  Duration: 992.94 ms     Billed Duration: 993 ms Memory Size: 128 MB     Max Memory Used: 128 MB
null

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

  1. OS: Mac (M1 arm64)
  2. sam --version: SAM CLI, version 1.116.0
  3. AWS region: us-east-1
# Paste the output of `sam --info` here
{
  "version": "1.116.0",
  "system": {
    "python": "3.12.3",
    "os": "macOS-14.5-arm64-arm-64bit"
  },
  "additional_dependencies": {
    "docker_engine": "26.1.1",
    "aws_cdk": "Not available",
    "terraform": "1.3.9"
  },
  "available_beta_feature_env_vars": [
    "SAM_CLI_BETA_FEATURES",
    "SAM_CLI_BETA_BUILD_PERFORMANCE",
    "SAM_CLI_BETA_TERRAFORM_SUPPORT",
    "SAM_CLI_BETA_RUST_CARGO_LAMBDA"
  ]
}

Add --debug flag to command you are running

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions