Unbound breakpoint - VS Code | Chrome | Angular

58,273

Solution 1

The fix for this was simple, I hadn't set the sourceMap property to true in angular.json for that particular environment, instead I had "sourceMap": false,

See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/SourceMap for more info.

With thanks to Connor - https://github.com/microsoft/vscode-js-debug/issues/872

Solution 2

In my case I needed to change webroot

FROM

"webRoot": "${workspaceFolder}"

TO "webRoot": "${workspaceFolder}\projectName"

Project name is the name you've given in the beginning ng new projectName

Then breakpoint bound.

Solution 3

For me, vscode setting:

Debug > Javascript: Use Preview which causes breakpoints to not hit by debugger.

Uncheck Debug > Javascript: Use Preview in vscode settings.

(or in settings/workspace json file) add:

"debug.javascript.usePreview": false

Solution 4

Tried all above and restart still not hitting. No error, not hanging, the whole application is like a breakpoint is hit now waiting for your to continue, yet you just don't see any breakpoint is being hit. However stand-alone browsers Chrome and Edge all running fine.

Note, this is not just Angular, it occurs on Node backend as well!

So besides setting all above, Run -> Disable All Breakpoints, then Enable All Breakpoints solved it.

2021-09-17, today it stops working again regardless. Finally adding a new breakpoint get it back. This behavior maybe related to debugger extremely lagging. Definitely a bug of VSC.

Solution 5

This won't answer the question directly, but one general tip to know what the problem is : Set trace : true when you launch or attach your debugger. Stop the debugger. Look at the logs. The path should be in the debug console.

Go to this website to analyze your log. https://microsoft.github.io/vscode-pwa-analyzer/index.html

Click on sourcemap.parsing and runtime.sourcemap in the tag filters. You will see things like this : enter image description here

At least you now have a feedback loop to know how your launch.json affects the sourcemaps.

The launch file (circle in red) has also a lot of useful informations

Share:
58,273
SomeDeveloper
Author by

SomeDeveloper

Updated on December 18, 2021

Comments

  • SomeDeveloper
    SomeDeveloper over 2 years

    I have an Angular application that I am trying to debug in VS Code.

    When I compile and run the application (ng serve) the breakpoints are bound:

    enter image description here

    However, when I specify a different configuration e.g. -c qa or -c uat they are unbound:

    enter image description here

    1. Why are the breakpoints unbound when I specify a different configuration?
    2. How do I bind the breakpoints for a debug session targeting a particular environment?

    Relevant information

    angular.json sample environment configuration:
    "uat": {
      "fileReplacements": [
        {
          "replace": "src/environments/environment.ts",
          "with": "src/environments/environment.uat.ts"
        }
      ],
      "optimization": true,
      "outputHashing": "all",
      "sourceMap": false,
      "extractCss": true,
      "namedChunks": false,
      "extractLicenses": false,
      "vendorChunk": false,
      "buildOptimizer": true,
      "budgets": [
        {
          "type": "initial",
          "maximumWarning": "2mb",
          "maximumError": "5mb"
        },
        {
          "type": "anyComponentStyle",
          "maximumWarning": "6kb",
          "maximumError": "10kb"
        }
      ]
    },
    
    Software versioning:
  • Thiago Pereira Maia
    Thiago Pereira Maia almost 3 years
    When I try this I get this error: Cannot connect to runtime process, timeout after 10000ms - (reason: Cannot connect to the target
  • psulek
    psulek over 2 years
    @ThiagoPereiraMaia maybe they already set preview debugger as default and removed old one, which works, not really sure about that.
  • Timbo773
    Timbo773 over 2 years
    Thank you!!! I could not get this working today until finding your response.
  • JanBrus
    JanBrus over 2 years
    For Windows users use / in the path instead of \
  • VeganHunter
    VeganHunter over 2 years
    could you please elaborate how to "Set trace : true" ?
  • piter entity
    piter entity over 2 years
    @VeganHunter: just add to your launch.json file the following line: "trace": true
  • A. Wentzel
    A. Wentzel over 2 years
    I'm experiencing the same exact scenario as @Jeb50 and it started on about the same date 9/17/21. For me it's only a problem for a few TypeScript files and the other 50 files or so debugging still works fine.
  • user2078148
    user2078148 over 2 years
    Without this, I would not be able to solve the issue! Thanks a lot!
  • mgPePe
    mgPePe over 2 years
    No such setting in vscode anymore 1.62.3
  • SkyG
    SkyG over 2 years
    WORKING! I tried everything without success, the downgrade to v16 was the solution. Thank You!
  • psulek
    psulek over 2 years
    @mgPePe now when such setting does not exit, my solution is to have "type" set to "legacy-node" in "launch.json" file. You need to install extension "[Deprecated] Node Debug (legacy)" (id: ms-vscode.node-debug) to support this type.
  • Erik Ostermueller
    Erik Ostermueller over 2 years
    runtime.sourcemap does not show up, but sourcemap.parsing does. Perhaps this is part of my problem.
  • AbhishekS
    AbhishekS over 2 years
    @jeb50 for me your answer didnt fix but atleast changed from "Unbound breakpoint" to "No symbols have been loaded for this document"
  • AceMark
    AceMark about 2 years
    this is really helpful if you have multiple projects within your workspace.
  • nhaggen
    nhaggen about 2 years
    It's always worth a try before going search for faulty configurations... and if your're lucky (it was my case) it solves the problem. (don't ask why).
  • Stephane
    Stephane about 2 years
    I downgraded Node to v16.14.2 but it changed nothing. I still have the unbound breakpoint issue.
  • Stephane
    Stephane about 2 years
    I added this default configuration property but it changed nothing. I still have the unbound breakpoint issue.
  • Stephane
    Stephane about 2 years
    I could see the log but I could not find anything that made sense to me. There was no FATAL nor ERROR at all.
  • Jake_3H
    Jake_3H almost 2 years
    Worked for me as well. Thanks!