'Waiting for debugger to disconnect... - Node.js in VSCode

I'm trying to step through a simple javascript example in Visual Studio Code, but the debugger hangs trying to disconnect.

macOS Sierra version 10.12.6

VSCode version 1.18.1 (up to date)

Node.js v8.9.2 (up to date) installed with Homebrew

Debugging with inspector protocol because Node.js v8.9.2 was detected.
node --inspect-brk= /*(port)*/ jsSandbox.js 
Debugger listening on ws:// (ip address)
Debugger attached.
Waiting for the debugger to disconnect...

This seems like it's been a closed issue with both Code and Node already, which is why I'm so confused. Am I doing something wrong?

Here is the only javascript file I'm trying to debug:

// learning about closure

function increase() {  // — gets called once
    var getBig = 0;
    return function() {  // — — gets called each time 
        getBig += 1;      // — — increments each time
        console.log(getBig);
    };
}
var bigOne = increase(); // --  a reference to the instance of the function
bigOne(); //1
bigOne();//2 

...and the project's launch.json config:

        {
            "type": "node",
            "request": "launch",
            "name": "Launch Program",
            "program": "${workspaceFolder}/jsSandbox.js",
            "console": "internalConsole"
        }


Solution 1:[1]

click on the button as shown below to open launch.json-

To open Launch.json

Give your correct file name here, where your server is starting. In my case it is app.js

"version": "0.2.0",
"configurations": [
    {
        "type": "node",
        "runtimeVersion": "10.21.0", 
        "request": "launch",
        "name": "Launch Program",
        "program": "${workspaceFolder}/app.js"
    }
]

runtimeVersion is optional, its required if you want to run it on a specific node version.And that node version should be installed on your system.

Solution 2:[2]

I found a syntax error in my code. The problem was that I wasn't catching the exception. Using VS Code, I just ticked "Uncaught Exceptions" and found the faulty code.

Solution 3:[3]

You should make sure the tab showing problems is empty, i.e., you should address all problems. In cases where the problems are from the files in node_modules, the problems go away just by closing those windows.

For example in the following pictures, there are 4 issues in Problems tab. Fixing them will make the debugger to work correctly!

enter image description here

Solution 4:[4]

Use $'{file} for active window:

{

  "version": "0.2.0",
  "configurations": [{
    "type": "node",
    "request": "launch",
    "name": "Active window",
    "program": "${file}"
  }]
}

Solution 5:[5]

For me a dependency crashed while debugging, which seems to also crash the vscode debugger itself. Restarting VSCode would allow me to debug again. Removing the faulty dependency (i.e. fixing the code, as suggested in the other answer), allows the debugging process to close, although the Debug Console message still was confusing:

Debugger listening on ws://127.0.0.1:48673/54esaf46-659e-sd92-5e45-01e78845825e
Debugger attached.
Waiting for the debugger to disconnect...

It would appear the debugger can't disconnect. But I have no trouble starting a new debug session afterwards.

Solution 6:[6]

Check your launch.json file. Its present in folder .vscode in your project. In launch.json change program value to ${workspaceFolder}/.

Solution 7:[7]

For me what helped was the following:

  1. created another new debugger anywhere in the program.
  2. Run the new debugger
  3. Stop the new debugger from the play/stop/step menu

It kind of resets the debugger I think from this "can't disconnect" glitch.

Solution 8:[8]

I found multiple "Node Debug" extensions installed. "React Native Tools" had a dependency on both of these. After I removed the "React Native Tools" and then the "Node Debug" extensions, VS Code resumed normal and expected behavior of running the debugger. I used the default launch configuration:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Launch Program",
            "program": "${workspaceFolder}/bin/www"
        }
    ]
}

Solution 9:[9]

It happens when you break your code. Start your project and you'll see that your app is crashing. Fix the problem and you'll be able to debug again.

Solution 10:[10]

you may check .json { "type": "node", "request": "launch", "name": "????", "program": "${workspaceFolder}/main.js" }

Solution 11:[11]

This happened for me when I added wrong file path in protractor.conf.js specs[]. I forgot to add file extension.

Solution 12:[12]

I found I had the Chrome Debugger tools open in another tab, that was the one that was holding it up. Just close that one.

Solution 13:[13]

I opened the Task Manager and stopped this process:

qemu-system- X86_64.exe (4)

See example

Solution 14:[14]

Please check your code firstly, there should be some issues when it compiles your code.