Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto Attach for node js not working, Breakpoints not hit #146932

Closed
jameswestbv opened this issue Apr 6, 2022 · 9 comments
Closed

Auto Attach for node js not working, Breakpoints not hit #146932

jameswestbv opened this issue Apr 6, 2022 · 9 comments
Assignees
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues *duplicate Issue identified as a duplicate of another issue(s)

Comments

@jameswestbv
Copy link

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.66.0
  • OS Version: Linux x64 5.13.0-37-generic (Ubuntu 20.04.3 LTS)

Steps to Reproduce:

  1. Launch any node.js file from the terminal
    Debugger should auto attach (it does on Windows) and hit the break point - but it doesn't on Ubuntu
Ubuntu.mp4

Version: 1.66.0
Commit: e18005f
Date: 2022-03-30T05:50:41.156Z
Electron: 17.2.0
Chromium: 98.0.4758.109
Node.js: 16.13.0
V8: 9.8.177.11-electron.0
OS: Linux x64 5.13.0-37-generic


Expected behaviour on Windows 11 - same version of VS Code

Windows.mp4

Version: 1.66.0 (system setup)
Commit: e18005f
Date: 2022-03-30T05:50:14.623Z
Electron: 17.2.0
Chromium: 98.0.4758.109
Node.js: 16.13.0
V8: 9.8.177.11-electron.0
OS: Windows_NT x64 10.0.22000

@weinand weinand added the debug Debug viewlet, configurations, breakpoints, adapter issues label Apr 6, 2022
@weinand weinand removed their assignment Apr 6, 2022
@connor4312
Copy link
Member

Can you please run echo $NODE_OPTIONS in your terminal and let me know what/if anything is printed?

@jameswestbv
Copy link
Author

james@dev-api-101:~/test$ echo $NODE_OPTIONS
--require /home/james/.config/Code/User/workspaceStorage/83b135b3ec7cd3dbb3f565ff7bcfca1d/ms-vscode.js-debug/bootloader.js

@philippe-wm
Copy link

Same issue on Mac OS Monterey, M1 Pro. Switching Node from 16 Arm to 14 x86 doesn't help.

I can run with --inspect-brk and then use "Debug: Attach to Node Process" to debug.

@Platonn
Copy link

Platonn commented Oct 13, 2022

Same for me. It doesn't attach automatically.
VS Code 1.72.0. Mac OS Monterey v12.1. Macbook 2020 M1. Node v16.17.0

@Platonn
Copy link

Platonn commented Oct 13, 2022

Now I figured out what was wrong. I had some custom NODE_OPTIONS exported in my .bashrc. When I removed it, the Auto Attach feature started to work:

export NODE_OPTIONS="--max-old-space-size=8192"

I discovered that by enabling AutoAttach in VSCode, the VSCode is setting NODE_OPTIONS and VSCODE_INSPECTOR_OPTIONS, e.g.:

NODE_OPTIONS=--require "/Users/<User>/Library/Application Support/Code/User/globalStorage/ms-vscode.js-debug/bootloader.js" --max-old-space-size=8192 ${env:NODE_OPTIONS}
VSCODE_INSPECTOR_OPTIONS=${env:VSCODE_INSPECTOR_OPTIONS}:::{"inspectorIpc":"/var/folders/8s/2dg05wjn62s42zzbvwm2by2w0000gn/T/node-cdp.10069-11.sock.deferred","deferredMode":true,"waitForDebugger":"","execPath":"/Users/<User>/.nvm/versions/node/v16.17.0/bin/node","onlyEntrypoint":false,"autoAttachMode":"always"

So my NODE_OPTIONS from my .bashrc overwritten the value set by VSCode. And that's why Auto Attach feature didn't work.

--
Finally, instead of removing my custom NODE_OPTIONS from .bashrc I just concatenated my options with whatever was set before (in this case: by VSCode), by including variable $NODE_OPTIONS as part of the string value:

export NODE_OPTIONS="$NODE_OPTIONS --max-old-space-size=8192"

@WookashWackomy
Copy link

@Platonn You've just saved an hour or two for me! I did not think that VSCode might make use of NODE_OPTIONS for debugging purposes...

@connor4312
Copy link
Member

@jameswestbv do you have capabilties set on your Node binary? You may be hitting nodejs/node#37588

@jameswest368
Copy link

@connor4312 Yep - that seems to be it.

Doesn't seem like anyone is in a hurry to fix it - probably one of those things that people think that setcap shouldn't really be used and things should run purely unprivileged... 🥱

So either change your code to not need setcap or, in my case, or give it a bit of this

sudo sysctl -w net.ipv4.ip_unprivileged_port_start=0

🙊

@connor4312
Copy link
Member

Thanks. Apologies for the slow response, I forgot about that issue at the time and this fell off my queue. Closing as a dupe of that one..

@connor4312 connor4312 added the *duplicate Issue identified as a duplicate of another issue(s) label Oct 19, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Dec 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues *duplicate Issue identified as a duplicate of another issue(s)
Projects
None yet
Development

No branches or pull requests

7 participants