AWS SAM CLI: Continue debugging automatically following start in VS Code?

0

When using AWS SAM CLI to debug Lambda function locally, the process in VS Code goes like this:

  1. Click Run / Press F5
  2. (SAM initializes in background, spins up docker container)
  3. VSCode opens a new tab called "index.js" with the entry point in it, and the debugger attaches and pauses.
  4. You must press Run / F5 again at this point, and close the "index.js" tab if you're not using it.

Is there any way to get this tool to skip step 4? I don't want it to open a new tab with entry point code in it - I'm not looking at that code or debugging it. It would also be really nice if the debugger just continued automatically following the attach. I find myself pressing F5 and closing index.js thousands of times per day.

Am I doing this wrong, or does everyone have to suffer through this?

1 Answer
1

Hello,

Tim here with the AWS Support Team!

Yes, I too ran into the same issue and was able to recreate this and understand what you’re running into and why this interrupts the debugging workflow.

I was able to do a bit of investigative work on my end, and I believe I traced the origins of this issue. I noticed when I inspected the call stack in Visual Studio Code it said “PAUSED ON DEBUGGER STATEMENT”, however I had set no breakpoint in that index.js file (located at /var/runtime/index.js according to the debugger).

Interesting I thought…so I began to dig around online what this message means, and I stumbled across an article online located here:

https://stackoverflow.com/questions/57357498/vscode-stops-on-invisible-breakpoint-on-async-hooks-js-while-debugging-a-node#:~:text=%22paused%20on%20debugger%20statement%22%20means,%3B%22%20statement%20in%20the%20code.

Now it appears the fix is to go into your Visual Studio Codes debug configuration and add a “skipFiles” section, and some documentation on that is located here: https://code.visualstudio.com/docs/nodejs/nodejs-debugging#_skipping-uninteresting-code

What thickens the plot a bit, when I went to add this “skipFiles” it said it was not supported, however digging into some GitHub issues, it appears it should be able to be ignored, and indeed I do see that other items are being ignored in the debug stack after I add some other folders to be ignored, so by all accounts its working on some spots: https://github.com/Microsoft/vscode-react-native/issues/620

Now with all that said, I was still not able to get past this specific file being ignored, I regret to inform you.

Still, I hope the information I shared above can help you pick up the investigation further..from all indications it appears to be more of a VS Code item rather than the AWS Toolkit (perhaps even the node.js debugger being at fault), so as the next steps I recommend opening an issue with the Visual Studio Code team and check if that can yield some results: https://github.com/microsoft/vscode

AWS
SUPPORT ENGINEER
Tim_P
answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions