[Fixed] Unbound breakpoint – VS Code | Chrome | Angular

Issue

My issue

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

Currently when I serve the application e.g. ng serve my breakpoints are bound and the breakpoints get hit:

enter image description here

However, when I serve via a different configuration e.g. ng serve -c qa or ng serve -c uat the breakpoints become unbound:

enter image description here

I can’t seem to find any relevant information on the internet (including SO) related to this issue.

Is there a reason why the breakpoints become unbound? How can I get the breakpoints to hit when serving with different environment configurations?

Relevant information

launch.json configuration:

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "chrome",
      "request": "launch",
      "name": "Launch Chrome against localhost",
      "url": "http://localhost:4200",
      "webRoot": "${workspaceFolder}"
    }
  ]
}

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:

Solution

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

Leave a Reply

(*) Required, Your email will not be published