简体   繁体   中英

Visual Studio Code Debugger Not Stopping at Breakpoints in SAM Local

I'm using AWS Lambda node 8.10, babel with in-line source-maps, and the latest VSCode (inspector protocol). When I start the debugger VSCode breaks at the entry point to of my lambda but won't stop at any subsequent breakpoints; the play button just moves past the entry point and the function runs to completion. If I check the "All Exceptions" check box it stops at other places in the code where excepting occur but still not my breakpoints.

Any idea how to make it stop at my breakpoints.

I had the same issue: the VS Code debugger hitting some breakpoint, but not that of my handler. I traced it down to the running directory not being what VS Code expected.

In my launch.json, I had to change

"localRoot": "${workspaceRoot}",

to

"localRoot": "${workspaceRoot}/hello_world", // or whatever folder your handler lives in

I also noticed that the edit-debug cycle is:

  • edit file
  • sam local invoke -d 5858
  • F5 in VS Code
  • debug
  • continue. This stops the debugging and the cycle repeats.

sam local start-api was a bit better in the sense that I didn't have to reinvoke the cli again, but I still had to reattach after starting another HTTP request, which I thought was weird.

Assuming, you want to see how your code behaves, and not just stop it. How about Using a debugging solution for live lambdas like Rookout ?

Bets part, it works not only in SAM local, but on deployed functions in AWS as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM