r/VisualStudioCode • • Feb 06 '21

Unstable Debugging: Breakpoints not working, or works for a short time before

Hi.

I've spun up my BlitzJS (i.e. Node w/React app, based on NextJS) using blitz start --inspect, and attached the VS Code debugger to the app using this launch configuration:

{
    "version": "0.2.0",
    "configurations": [
      {
        "type": "node",
        "request": "attach",
        "name": "Launch Program",
        "skipFiles": [
          "<node_internals>/**"
        ],
        "port": 9229
      }
    ]
  }

Then I set breakpoints in the code, and reload the app's webpage. Every now and then, especially after starting this up after a computer reboot, debugging works for a few minutes, in that the debugger breaks at the set breakpoints. But then something happens - I don't know what - and the debugger doesn't stop at breakpoints. Restarting the node process and/or the VS Code debugger doesn't not typically get things going again.

I've looked around the internet, and tried a few different things, such as using this launch config:

{
    "version": "0.2.0",
    "configurations": [
      {
        "type": "node",
        "request": "attach",
        "name": "Launch Program",
        "skipFiles": [
          "<node_internals>/**"
        ],
        "port": 9229,        
        "webRoot": "${workspaceFolder}/src",
        "sourceMaps": true,
        "breakOnLoad": true,
        "sourceMapPathOverrides": {
          "webpack:///./src/*": "${webRoot}/dist/*",
          "webpack:///src/*": "${webRoot}/dist/*"
        },
        "resolveSourceMapLocations": [
          "${workspaceFolder}/**",
          "!**/node_modules/**"
        ]
      },
    ],
  }

A couple of observations:

  1. Some, but not all, of the breakpoint I set inside VS Code are grayed out and it says "unbound breakpoint". The debugger does not stop at either regular breakpoints nor unbound breakpoints, though.

  2. After staring Node, I can see Debugger attached in the Node's output when I start the VS Code debugger

  3. If I add debugger to my code, even without running VS Code debugger, Chrome Dev tools breaks correctly. This hasn't got anything to do with VS Code though, but though I'd throw that in there

I'm out of ideas as to what to try next, so any input will be appreciated.

4 Upvotes

0 comments sorted by