Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 550
Jason Leach Avatar asked Jun 04 '18 15:06

Jason Leach


People also ask

How do I stop a Visual Studio Debug session?

To end a debugging session in Microsoft Visual Studio, from the Debug menu, choose Stop Debugging.

Why breakpoint is not hitting with VS code?

If a source file has changed and the source no longer matches the code you're debugging, the debugger won't set breakpoints in the code by default. Normally, this problem happens when a source file is changed, but the source code wasn't rebuilt. To fix this issue, rebuild the project.

What happens when a breakpoint is reached when the debugger is enabled?

If a breakpoint is reached, or a signal not related to stepping occurs before count steps, stepping stops right away. Continue to the next source line in the current (innermost) stack frame. This is similar to step , but function calls that appear within the line of code are executed without stopping.

Why doesn't the debugger stop on breakpoints when I debug?

This article helps you resolve a problem where the debugger doesn't stop on breakpoints when you debug ASP.NET applications in Microsoft Visual Studio .NET. When you debug ASP.NET applications in Visual Studio .NET, the debugger might not stop on breakpoints. This problem occurs because ASP.NET debugging isn't enabled on the application.

How do I enable breakpoints in Visual Studio Code?

Breakpoints can be toggled by clicking on the editor margin or using F9 on the current line. Finer breakpoint control (enable/disable/reapply) can be done in the Debug view's BREAKPOINTS section. Breakpoints in the editor margin are normally shown as red filled circles.

Are there any errors when debugging with Visual Studio Code?

There are no apparent errors – the code simply executes all the way through without ever stopping on the breakpoint. Both Visual Studio and the application you’re debugging need to be running with the same level of elevation.

How do I debug a program in VS Code?

VS Code debuggers typically support launching a program in debug mode or attaching to an already running program in debug mode. Depending on the request (attach or launch), different attributes are required, and VS Code's launch.json validation and suggestions should help with that.


1 Answers

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.

like image 72
ivanmartinvalle Avatar answered Sep 21 '22 14:09

ivanmartinvalle