-
Notifications
You must be signed in to change notification settings - Fork 348
Description
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:
- Add this to
.wslconfig:
[wsl2]
networkingMode = mirrored
- Use the snippets below :
// main.js
const output = require('node:child_process').execSync("npm config get registry");
console.log(output.toString());- Add a breakpoint to line 1 (
execSync()line) in the program. - Now run the program, and attach to it:
NODE_OPTIONS="--inspect-brk" node ./main.js- 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