To fix this and debug Node SAM Local Lambda functions I had to read the Node.js debug docs (https://code.visualstudio.com/docs/nodejs/nodejs-debugging#_supported-nodelike-runtimes).
Specifically the portion that solved this problem on my side related to the "Legacy" vs "Inspector" debug protocols. For Node >8.0 Legacy Debug protocol needs to be used.
Since the Lambda Runtime relies on Node 6.10 "Legacy" Protocol had to be used on my end.
At first I didn't think this could possibly be the issue since the SAM Local node VS Code configuration actually in-correctly (at least for me) references the "Inspector" protocol in their docs, while correctly referencing the "Legacy" protocol in the Gif (see below) inside of those same docs.
For those who would like to try that out, here is what my WORKING launch.json needed to look like.
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to SAM Local",
"type": "node",
"request": "attach",
"address": "127.0.0.1",
"port": 8000,
"localRoot": "${workspaceRoot}/dist",
"remoteRoot": "/var/task",
"protocol": "legacy"
}
]
}
The most important part of that is: "protocol": "legacy"
I assume that you can swap 127.0.0.1 back to localhost, and port back to 5858 (rather than 8000) since those are all fragments of my varied attempts to find a solution but I have not tried that just yet.
I will submit a pull request to the AWS SAM Local README.md on github (found here: https://github.com/awslabs/aws-sam-local#debugging-applications) as soon as I get a minute. Hope this helps others in the interim!
Compare the above to the docs which as of the time of this posting still list the following JSON as the correct settings for the VS Code launch.json file:
INCORRECT JSON that does not work but is referenced in the docs (DO NOT USE THIS ONE):
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to SAM Local",
"type": "node",
"request": "attach",
"address": "localhost",
"port": 5858,
"localRoot": "${workspaceRoot}",
"remoteRoot": "/var/task",
"protocol": "inspector"
}
]
}