Skip to content

Debugger may hang if a firewall is active #2004

@tusharsnx

Description

@tusharsnx

Describe the bug

const r = spawnSync('nc', ['-z', '127.0.0.1', String(port)]);

The vscode js debugger seems to use nc (netcat) for testing arbitrary ports to be available for the debugger to use. This works fine, except when a firewall is active on the system which can block access to ports in a way where the application would never see a reply coming back so they would just hang. In this case, nc never receives a reply and keeps waiting for it , and the debugger blocks on that (until it eventually times out).

I'm using WSL's new networkingMode=mirrored mode that comes with a firewall that by default blocks requests in the way I described above (no reply sent). I think it's important to wrap the call with a reasonable timeout that is also small. nc does give an option to set a timeout with -w option. This should be set within a range of a few seconds.

To Reproduce
Steps to reproduce the behavior:

  1. Add this to .wslconfig:
[wsl2]
networkingMode = mirrored
  1. Use the snippets below :
// main.js

const output = require('node:child_process').execSync("npm config get registry");
console.log(output.toString());
// launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "attach",
            "name": "Attach Program",
        }
    ]
}
  1. Add a breakpoint to line 1 (execSync() line) in the program.
  2. Now run the program, and attach to it:
NODE_OPTIONS="--inspect-brk" node ./main.js
  1. Once the debugger is attached, press "Step over" and observe the program being hung.

In the background, node has started npm config get registry, but before the npm's node instance could run, node called the debugger code, and the debugger called nc command that is now hung waiting for a reply. On my system, it eventually resumes after the nc returns due to the (~2 mins) default timeout (?)

VS Code:
Version: 1.88.1 (user setup)
OS: Windows_NT x64 10.0.22631

Metadata

Metadata

Assignees

Labels

bugIssue identified by VS Code Team member as probable bugverifiedVerification succeeded

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions