question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Could not connect to the debugger when using the default port (0)

See original GitHub issue

Expected Behavior

Recently, I upgraded our project from Angular 8.x to 9.x, Nest 6.x to 7.x and Nx 8.x to 9.x. Since then the debugger could not connect to the process.

image

Current Behavior

After the upgrade and migration, only passWithNoTests been added to the angular.json and there were no changes to nx.json and any of the tsconfigs. It is not working even without the changes to the files and only using the upgraded dependencies.

I am running the project from the terminal using ng serve and I tried reopening VScode, removing/reinstalling node_modules and also debugging using the Chrome’s dedicated Node DevTools for Node.js.

When adding port to the options in angular.json it works without any problem. So it is probably related to #2510.

Steps to Reproduce

You can find my repro here. In master branch you can find the files before the upgrade, and in nx9 branch the upgraded version.

Or just run the following steps:

  1. Create a new workspace using the latest v8:

    npx create-nx-workspace@8.12.9 repro-nx-nest-debug
    
  2. Upgrade nx:

    yarn update
    
  3. Add a breakpoint and run the api:

    yarn start api
    
  4. Try to attach to the process using the options Debug: Attach to Node process from the Command Palette....

Context

  • I’m using VSCode 1.43.1 and Node.js 12.8.1
nx report
  @nrwl/angular : 9.1.2
  @nrwl/cli : 9.1.2
  @nrwl/cypress : 9.1.2
  @nrwl/eslint-plugin-nx : Not Found
  @nrwl/express : Not Found
  @nrwl/jest : 9.1.2
  @nrwl/linter : 9.1.2
  @nrwl/nest : 9.1.2
  @nrwl/next : Not Found
  @nrwl/node : 9.1.2
  @nrwl/react : Not Found
  @nrwl/schematics : Not Found
  @nrwl/tao : 9.1.2
  @nrwl/web : Not Found
  @nrwl/workspace : 9.1.2
  typescript : 3.7.5
Relevant packages
  @angular-devkit/build-angular@0.900.6
  @angular/cli@9.0.6
  @angular/common@9.0.7
  @angular/compiler@9.0.7
  @angular/compiler-cli@9.0.7
  @angular/core@9.0.7
  @nestjs/common@7.0.3
  @nestjs/core@7.0.3
  @nestjs/jwt@7.0.0
  @nestjs/passport@7.0.0
  @nestjs/platform-express@7.0.3
  @nestjs/platform-socket.io@7.0.3
  @nestjs/schematics@7.0.0
  @nestjs/serve-static@2.1.0
  @nestjs/swagger@4.4.0
  @nestjs/testing@7.0.3
  @nestjs/typeorm@7.0.0
  @nestjs/websockets@7.0.3
  core-js@3.6.4
  ts-node@8.6.2
  tslib@1.11.1
Relevant project configuration in angular.json
  "server": {
    "root": "apps/server",
    "sourceRoot": "apps/server/src",
    "projectType": "application",
    "prefix": "server",
    "schematics": {},
    "architect": {
      "build": {
        "builder": "@nrwl/node:build",
        "options": {
          "outputPath": "dist/apps/server",
          "main": "apps/server/src/main.ts",
          "tsConfig": "apps/server/tsconfig.app.json",
          "assets": ["apps/server/src/assets"]
        },
        "configurations": {
          "production": {
            "optimization": true,
            "extractLicenses": true,
            "inspect": false,
            "fileReplacements": [
              {
                "replace": "apps/server/src/environments/environment.ts",
                "with": "apps/server/src/environments/environment.prod.ts"
              }
            ]
          }
        }
      },
      "serve": {
        "builder": "@nrwl/node:execute",
        "options": {
          "buildTarget": "server:build"
        }
      },
      "lint": {
        "builder": "@angular-devkit/build-angular:tslint",
        "options": {
          "tsConfig": [
            "apps/server/tsconfig.app.json",
            "apps/server/tsconfig.spec.json"
          ],
          "exclude": ["**/node_modules/**", "!apps/server/**"]
        }
      },
      "test": {
        "builder": "@nrwl/jest:jest",
        "options": {
          "jestConfig": "apps/server/jest.config.js",
          "maxWorkers": 3,
          "tsConfig": "apps/server/tsconfig.spec.json",
          "passWithNoTests": true
        }
      }
    }
  }

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

26reactions
fsystemdevelopmentcommented, Apr 14, 2020

For anyone having the same issue, fast solution add port to angular.json in section see attached port

0reactions
micaelmbagiracommented, Jan 20, 2021

@Cammisuli Do you have an example (launch.json) config that works with the new VSCode debugger and "port": 0?

Read more comments on GitHub >

github_iconTop Results From Across the Web

ruby - Could not connect to debugger on port xxxxx for rails ...
Do you already have something else, like another project, running on port 50671? This error is usually thrown when the port is already...
Read more >
Remote Debugging does not connect to specified port over SSH
It looks like Visual Studio has a bug where you can only SSH into a single port per IP address for remote debugging....
Read more >
Unable to Connect to the Microsoft Visual Studio Remote ...
Visual Studio could not connect to the remote debugger. This message may occur for several reasons: The remote debugger may be running under...
Read more >
Troubleshooting common PHP debugging issues
When the debugger cannot connect or refuses the connection, check the following: Make sure Xdebug or Zend Debugger are configured to connect to...
Read more >
Debugging - Getting Started | Node.js
Even if you bind the inspector port to 127.0.0.1 (the default), any applications running locally on your machine will have unrestricted access. This...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found