Debugging TypeScript Lambda locally via launch.json in VS Code DevContainers does not work
- Dominant language
- TypeScript
- Stars
- 2k
- Forks
- 807
- Avg merge
- 10h 12m
- Merged PRs (30d)
- 7
Description
## Problem
If you try to run debugging using a configuration from `launch.json` when running from a DevContainer, it doesn't work.
I think it has something to do with the SAM container not being able to reach the source files from inside the container, since the path being supplied is a volume mapped file that points to the DevContainer.
## Steps to reproduce the issue
**Sample launch configuration:**
```json
{
"type": "aws-sam",
"request": "direct-invoke",
"name": "src:HelloWorldFunction (nodejs14.x)",
"invokeTarget": {
"target": "template",
"templatePath": "${workspaceFolder}/template.yaml",
"logicalId": "HelloWorldFunction"
},
"lambda": {
"payload": {},
"runtime": "nodejs14.x"
}
}
```
1. Create any blank SAM project with the CLI.
2. Enable DevContainers for the project.
3. Enable Docker in Docker for the DevContainers (mounting Docker sockets etc, and installing Docker in the Dockerfile).
4. Create a `launch.json` with the above configuration (or any configuration really).
5. Launch the configuration.
6. Watch as the following error or similar pops up: `[ERROR]: Error running command "sam local invoke": Timeout token expired`.
## Expected behavior
I expected the launch configuration to work within DevContainers.
## System details (run the `AWS: About Toolkit` command)
**Note:** This is run within the DevContainer, so my host OS is Mac.
OS: Linux x64 5.15.49-linuxkit
Visual Studio Code extension host: 1.76.2
AWS Toolkit: 1.65.0
node: 16.14.2
Contributor guide
Research direction
Start by reproducing the failure with the sample launch.json, template.yaml, a DevContainer, and Docker-in-Docker setup, then inspect the sam local invoke timeout. Compare how the DevContainer and SAM container resolve the workspace and mounted source path; done means the launch configuration completes successfully and local debugging works inside the DevContainer.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, docker, node.js, typescript, vscode
- Domain
- developer-experience, devops, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100