-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Debugging config for renderer + main process #465
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
Comments
Thanks for you config. Thanks to you i can debug the main-process now. Would be awesome if we manage to get the debugger for the render process working. |
I can debug the renderer. I will note that our repository has not updated from upstream (this repo) in a while, however we are up to date with Electron (8.2.3) and Angular (9.1.2) as of a few days ago. In package.json I've changed the starting of Electron to look like: "electron:serve": "wait-on http-get://localhost:4200/ && npm run electron:serve-tsc && electron . --serve --remote-debugging-port=9222", Note the addition of a specific port. start your app (npm start), if you have Chrome debugger tools open, close them as I believe only one debugger can be active. Then using this config, attach to your app:
Running 4.12.6 of the Chrome Debugger extension. Note the biggest drawback of the VS debugging is that after you make a code change and the app automatically compiles and restarts you lose the debugger/Chrome connection. So you have to press the"disconnect" debugger button, then run your attach debugger config again. For this reason I mostly just use the built in Chrome debugging tools, and only use the VS Chrome debugger for main process. If the above config doesn't work for you let me know and I'll try a fresh clone of this repo and see if I can get it to work. |
Hey @greg9504 , replaced my npm script and added the renderer config above but I must be doing something wrong. The chrome debugger seems to be attaching correctly, but I'm still getting the The branch with the config I tried out looks like this. Can't for the life of me figure out what I'm doing wrong, so figured I'd upload a screen recording in case as well. I'm also on v4.12.6 of the extension. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I did try your repo and could not get it to work either. Everything looks very similar.
Working
I'm not sure why yours does not work. |
After a long time trying to get renderer process to hit breakpoints in vs code, I finally got it. Launch.json:
tasks.json:
in package json you have to make ng to generate source maps for your code:
So when you run Electron:Renderer, through prelaunch task start, it will npm start electron, it will create sourcemaps for the angular, serve angular at 4200 and debugging at 9222, since webroot is set to /src/app/ when you hit breakpoint or "debugger;" it will show on the vscode correctly. (BTW I do not have Electron :Main here, and dont use it , instead I have a prelaunch task start) Here is my trial and error: If you set wrong webroot, Breakpoints do not hit. But "debugger;" will hit but will show in other files. "debugger;" in app.component.ts will make a pause in main.js so web root is : /src/app as above is necessary. As for the source map path overrides, with webroot: /src/app, wrong sourcemap overrides will make you hit the "debugger;"s, but not breakpoint, Also it will hit debuggers on a readonly source file which is reverse generated from inlined sourcemap. On this source file you can set breakpoints after debugger, see values but, when you make changes on original source file and hot reload, the regenerated source file will stay same and will not reflect changes. and thus will show wrong debugger locations. and still no breakpoints. so as a result: "sourceMapPathOverrides" with above values, will enable hot reload, live changes and correctly working breakpoints BTW I do not debug electron main from this and not interested because my main.ts is stale for me right now. so this does not include debugging electron side. You need debugger for chrome extension for this to work. Also if you do not want to see js and js.map files in vs code put:
in settings.json of vscode and dont forget to exclude them
in your gitignore so they dont get uploaded to your repo. one more thing I also put sourcemap:true and evalsourcemap:false in angular.json under serve, dont know if it helps
Best of luck, this vscode angular, electron, debugging was super annoying for me, hope you will make it work. Edit: Multiple BrowserWindows: So if you start debugging with prelaunchtask of electron, the initial window will be debugged. If you comment out prelaunchtask, start electron manually (npm start) then run the launch, it will give you the option to connect the Browserwindow you like. It will show on top similar to launch task shortcut. From my understanding it can only debug one window at a time. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
There have been quite a number of issues opened here related to debug configs, however, few of the solutions proposed are updated nor optimal. It's perhaps outside the scope of this repo and I don't believe the author has an obligation to address this, but I still feel like this is a good forum to get this figured out.
The config I'm using to debug currently looks like this (full repo is here):
The issue I'm running into with the above config is that breakpoints aren't hitting in the render process (VSCode is showing the error
Breakpoint ignored because generated code not found (source map problem?)
). I can debug the main process just fine with the above config, which is awesome. The chrome debugger also seems to be attaching correctly (can see the outputs in the debug console).Just adding
debugger;
statements to the Angular code lets me debug in the chrome devtools in the Electron window, but it would be far far better to debug inside VSCode.Any ideas on how to get the Chrome debugger working on the render process?? I'd be happy to open a PR once a working debugging conf is found (if the author is OK with that).
The text was updated successfully, but these errors were encountered: