VSC 10.6 does not allow to attach debugger to running Electron app (working great with 10.3)
VSC 10.6 does not allow to attach the debugger to a running Electron (0.36.2) app. I was able to downgrade VSC by downloading from here to version 10.3: https://github.com/Microsoft/vscode/wiki/Previous-Releases.
VSC 10.3 is allowing to attach the debugger to a running Electron app with these simple settings: { "name": "Attach", "request": "attach", "type": "node", // TCP/IP address. Default is "localhost". //"address": "localhost", // Port to attach to. "port": 5858, "sourceMaps": false } Thanks for your support.
CC @weinand
@rscharnetzki could you please try to use a different port than 5858. Does it make a difference?
I tested it now with Port 5859. Same issue as before, this does not fix it. VSC 10.6 will not complain when I am attaching the debugger to the running Electron app, it looks as if the debugger is properly attached but it will never stop at any break-point. VSC 10.5 is showing the same behavior as 10.6. Some change between 10.3 and 10.5 seems to be causing this.
Thanks again for looking into this.
{ "name": "Attach", "request": "attach", "type": "node", // TCP/IP address. Default is "localhost". //"address": "localhost", // Port to attach to. "port": 5859, "sourceMaps": false }
@rscharnetzki what is your Electron setup? Do you have reproducible steps?
@rscharnetzki I have working debugging of electron 0.36.0 and VSCode 0.10.6. My launch.json is
{
"name": "Run App",
"type": "node",
"program": "./build/background.js",
"stopOnEntry": false,
"args": [],
"cwd": ".",
"runtimeExecutable": "./node_modules/electron-prebuilt/dist/electron.exe",
"runtimeArgs": [],
"env": {
"NODE_ENV": "development"
},
"sourceMaps": false,
"outDir": null
}
File background.js is file where i create "main process" Main window.
This will allow me to debug "Main process". BUT does not work for "renderer process". I dont know how to configure it (or if its possible) to be able to debug also "renderer process".
I'm having the same problem with my express app. Attach debugging stopped working when i updated to version 0.10.5. Launch debug seems to be working correctly.
I am also experiencing this problem with VSCode 0.10.6 & Electron 0.36.4 on Win7 x64.
+1
My current workaround is to debug the code under developer tools :-(
I've tried to reproduce the problem in VS Code 0.10.6 (but couldn't). Here is what worked for me (on OS X).
From a command line:
git clone https://github.com/atom/electron-quick-start
cd electron-quick-start
npm install
./node_modules/electron-prebuilt/dist/Electron.app/Contents/MacOS/Electron --debug-brk main.js
My VS Code launch config looks like this:
{
"name": "Attach",
"type": "node",
"request": "attach",
"port": 5858
}
Then I set a breakpoint in main.js:18 and and started the "Attach" session. I first stopped in init.js:1 and after a single "continue" I hit the breakpoint in main.js.
Please note: I'm starting electron with "--debug-brk" to make sure that breakpoints in startup code get properly registered. When starting electron with "--debug"only, it will run over the main.js code before VS Code has a chance to register the breakpoint in main.js.
BTW, here is the "launch" config for electron:
{
"name": "Launch",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/main.js",
"stopOnEntry": false,
"args": [],
"cwd": "${workspaceRoot}",
"runtimeExecutable": "${workspaceRoot}/node_modules/electron-prebuilt/dist/Electron.app/Contents/MacOS/Electron",
"runtimeArgs": [
"--nolazy"
],
"env": {
"NODE_ENV": "development"
}
}
Here it is not necessary to set stopOnEntry to true in order to get the breakpoint in main.js hit because VS Code behind the scenes always launches the debugger with "--debug-brk".
I did exactly what you said and it's still not working. The debugger stop on the first line but never stop on any breakpoint after hitting "Continue". The only difference with you that i can see is that i'm on Windows 7.
@lpproulx what exact command are you using to launch electron in debug mode?
I'm not using electron. I have a simple http server starting an express app. I'm using nodemon with this command: "nodemon --debug-brk".
I also tried with a more traditional "node local.js --debug-brk".
What is strange is that the same command was working fine in 0.10.3.
Edited: I don't know if it can make a difference but i'm using node v4.2.3
@lpproulx what version of node are you using?
4.2.3
@lpproulx and if you try to "launch" your express app from VS Code instead of "attach" does it make a difference?
Yes it's working fine with the "launch" config
I reinstalled the 0.10.3 version and attach seem to be working fine
@lpproulx I can reproduce this problem on Windows 7. I don't know yet what the culprit is, but I've already verified that it will be fixed in the upcoming January drop.
thank you!