4

It's debugging the wrong file when the debugger starts up.

enter image description here

Using SAM CLI 1.40 and latest VS Code. I followed directions here:

https://docs.aws.amazon.com/toolkit-for-vscode/latest/userguide/serverless-apps-run-debug-no-template.html

Here's my launch.json entry, generated by following directions above:

    {
        "type": "aws-sam",
        "request": "direct-invoke",
        "name": "videoPostUpload",
        "invokeTarget": {
            "target": "code",
            "projectRoot": "${workspaceFolder}/my-lambda-fn/videoPostUpload",
            "lambdaHandler": "index.lambdaHandler"
        },
        "lambda": {
            "runtime": "nodejs14.x",
            "payload": {},
            "environmentVariables": {}
        }
    }

Here's my function:

exports.lambdaHandler = async event => {
    const response = { //breakpoint here works properly, after /var/runtime/index.js!
        statusCode: 200,
        body: {
            message: "Hello SAM!"
        }
    };
    return response;
};

Instead, it launches /var/runtime/index.js first - even though there's no breakpoints in that file. Minor problem, but annoying if I include Lambda functions in my compound debugging configs, in launch.json. I'd rather not stop the debugger at this file every time I'm debugging across my entire platform.

Is there a way to exclude this file? Am I configured incorrectly?

Tsar Bomba
  • 1,047
  • 6
  • 29
  • 52

1 Answers1

1

I found a workaround for this problem, in VSCode, you can add the frames from the call stack to the excluded callers list. When it breaks at the entry point, right click on the callers and select Exclude Caller. You might need to exclude the first few callers.

Note: It appears this resets on VSCode relaunch

Exclude Caller

Ian-B
  • 484
  • 5
  • 10