Hello!
I try to debug my serverless application in vscode using localstack deploy but I failed!
I’m doing some tests with localstack where I use typescript in my lambda and is triggered by an SQS, which is why I was trying to debug it with localstack.
Some problems I’m facing:
- The breakpoint only works once, on the first call to the route. After that, it never falls to the breakpoint again. (and the breakpoint isnt the correct one)
- The breakpoint points to the .js file and not my .ts (I added sourceMaps and it still falls to .js)
launch.json
{
"version": "0.2.0",
"configurations": [
{
"address": "127.0.0.1",
"localRoot": "${workspaceFolder}",
"name": "Attach to Remote Node.js",
"port": 9229,
"remoteRoot": "/var/task/",
"request": "attach",
"type": "node",
"sourceMaps": true,
"preLaunchTask": "Wait Remote Debugger Server"
},
]
}
tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "Wait Remote Debugger Server",
"type": "shell",
"command": "while [[ -z $(docker ps | grep :9229) ]]; do sleep 1; done; sleep 1;"
}
]
}
docker-compose
version: '3.8'
services:
localstack:
container_name: client-localstack
image: localstack/localstack:latest
ports:
- '4566:4566'
- '4571:4571'
environment:
- SERVICES=s3,sns,sqs,lambda,apigateway
- DEBUG=1
- DATA_DIR=/tmp/localstack/data
- LAMBDA_EXECUTOR=docker
- LAMBDA_REMOTE_DOCKER=false
- LAMBDA_DOCKER_FLAGS=-e NODE_OPTIONS=--inspect-brk=0.0.0.0:9229 -p 9229:9229
- DOCKER_HOST=unix:///var/run/docker.sock
- AWS_ACCESS_KEY_ID=test
- AWS_SECRET_ACCESS_KEY=test
volumes:
- './.localstack:/tmp/localstack'
- '/var/run/docker.sock:/var/run/docker.sock'
Thank you for your time