sam debugging: breakpoint not hit for arm64 + packagetype=image node lambda functions
- Dominant language
- TypeScript
- Stars
- 2k
- Forks
- 807
- Avg merge
- 10h 12m
- Merged PRs (30d)
- 7
Description
## Problem
When creating an AWS Lambda function with nodejs18.x runtime and arm64 architecture using container images, the debugger does not stop at breakpoints. However, it works as expected when using x86_64 architecture.
## Steps to reproduce the issue
```sam init --name sam-test --package-type=Image --base-image amazon/nodejs18.x-base```
Add a debug configuration from codelens (after enabling it)
launch.json should look like this
```
{
"configurations": [
{
"type": "aws-sam",
"request": "direct-invoke",
"name": "sam-test:HelloWorldFunction (nodejs18.x)",
"invokeTarget": {
"target": "template",
"templatePath": "${workspaceFolder}/template.yaml",
"logicalId": "HelloWorldFunction"
},
"lambda": {
"payload": {},
"environmentVariables": {},
"runtime": "nodejs18.x"
}
}
]
}
```
Add a breakpoint in app.mjs, and it will work fine.
Now go to template.yaml and update the architecture from x86_64 to arm64.
```
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
sam-test
Sample SAM Template for sam-test
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
Function:
Timeout: 3
Resources:
HelloWorldFunction:
Type: AWS::Serverless::Function
Properties:
PackageType: Image
Architectures:
- x86_64
Events:
HelloWorld:
Type: Api
Properties:
Path: /hello
Method: get
Metadata:
DockerTag: nodejs18.x-v1
DockerContext: ./hello-world
Dockerfile: Dockerfile
Outputs:
# ServerlessRestApi is an implicit API created out of Events key under Serverless::Function
# Find out more about other implicit resources you can reference within SAM
# https://github.com/awslabs/serverless-application-model/blob/master/docs/internals/generated_resources.rst#api
HelloWorldApi:
Description: "API Gateway endpoint URL for Prod stage for Hello World function"
Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/hello/"
HelloWorldFunction:
Description: "Hello World Lambda Function ARN"
Value: !GetAtt HelloWorldFunction.Arn
HelloWorldFunctionIamRole:
Description: "Implicit IAM Role created for Hello World function"
Value: !GetAtt HelloWorldFunctionRole.Arn
```
Update the Architectures above to be arm64 and when running the debug again, you will notice that it no longer stops at breakpoints.
## Expected behavior
The breakpoints should work on both x86_64 and arm64 runtimes.
## System details (run the `AWS: About Toolkit` command)
OS: Darwin arm64 23.3.0
Visual Studio Code extension host: 1.86.2
AWS Toolkit: 2.11.0
node: 18.17.1
electron: 27.2.3
Contributor guide
Research direction
The reproduction uses launch.json, template.yaml, app.mjs, the SAM Image workflow, and the AWS: About Toolkit details. First reproduce the nodejs18.x direct-invoke debug with x86_64 and arm64 architectures, then trace the relevant VS Code debugger entry point. Done means breakpoints are hit for both architectures and the existing reproduction works as expected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, docker, node.js, typescript, vscode
- Domain
- cloud, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100