Breakpoint set but not yet bound for some files when using a Dockerized node process

Viewed 104

I have a server running inside a docker container that listens for a debugger on port 9229. Below is how my launch.json looks like

{
      "name": "Docker: Attach to Node",
      "type": "node",
      "request": "attach",
      "restart": true,
      "port": 9229,
      "address": "localhost",
      "localRoot": "${workspaceFolder}",
      "remoteRoot": "/app/",
      "protocol": "inspector",
      "skipFiles": [
        "<node_internals>/**"
      ]
    }

Inside the main app folder I have 3 sub-folders as shown below,

/app/api/v1

/app/tests/specs/

/app/utils/

I have the breakpoint set in multiple files across all these three subfolders but vs code is only recognizing the breakpoints set for the /app/api/v1 folder. For the breakpoints set in the rest of the folders, it says "Breakpoint set but not yet bound". Can someone please assist? I did go through similar questions in stack overflow but none of them helped.

enter image description here

1 Answers

I was able to fix this issue by following the below steps.

  1. Install Docker extension from VS Code marketplace.

enter image description here

  1. Click on the Docker icon and then right-click on your container which has node server running and select “Attach to VS Code“.

enter image description here

3. Add below configuration in your launch.json

    {
      "name": "Docker: Attach to container",
      "type": "node",
      "request": "attach",
      "restart": true,
      "port": 9229,
      "address": "localhost",
      "localRoot": "${workspaceFolder}",
      "remoteRoot": "/app",
      "sourceMaps": true,
      "cwd":"${workspaceFolder}",
      "protocol": "inspector",
      "skipFiles": [
        "<node_internals>/**"
      ],
    }
  1. Click on Run and Debug and select "Docker: Attach to container" from the drop-down. The debugger should be attached.
Related