question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Debugging config for renderer + main process

See original GitHub issue

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):

// .vscode/launch.json
{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "launch",
      "name": "Electron: Main",
      "protocol": "inspector",
      // Prelaunch task compiles main.ts for Electron & starts Angular dev server.
      "preLaunchTask": "Build: All",
      "cwd": "${workspaceFolder}",
      "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron",
      "runtimeArgs": ["--remote-debugging-port=9223", "--serve", "."],
      "windows": {
        "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron.cmd"
      }
    },
    {
      "name": "Electron: Renderer",
      "type": "chrome",
      "request": "attach",
      "port": 9223,
      "webRoot": "${workspaceFolder}",
      "timeout": 30000,
      "urlFilter": "http://localhost:4200/*",
      // Source map overrides are copied from Angular CLI debugging recipe.
      // See: https://github.com/Microsoft/vscode-recipes/tree/master/Angular-CLI
      "sourceMaps": true,
      "sourceMapPathOverrides": {
        "webpack:/*": "${webRoot}/*",
        "/./*": "${webRoot}/*",
        "/src/*": "${webRoot}/*",
        "/*": "*",
        "/./~/*": "${webRoot}/node_modules/*"
      }
    }
  ],
  "compounds": [
    {
      "name": "Electron: All",
      // The main process should be started before renderer to prevent timeout.
      "configurations": ["Electron: Main", "Electron: Renderer"]
    }
  ]
}
// .vscode/tasks.json
{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "Build: All",
      "type": "shell",
      "command": "npm run electron:serve-tsc && ng serve",
      "isBackground": true,
      "group": {
        "kind": "build",
        "isDefault": true
      },
      "problemMatcher": {
        "owner": "typescript",
        "source": "ts",
        "applyTo": "closedDocuments",
        "fileLocation": ["relative", "${cwd}"],
        "pattern": "$tsc",
        "background": {
          "activeOnStart": true,
          "beginsPattern": "^.*",
          "endsPattern": "^.*Compiled successfully.*"
        }
      }
    }
  ]
}

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).

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:7

github_iconTop GitHub Comments

1reaction
HaidStefancommented, Apr 12, 2020

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.

0reactions
stale[bot]commented, Jun 1, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Electron main and renderer process debug configuration
Debugging main process using Chrome using link like chrome-devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=127.0.0.1: ...
Read more >
Application Debugging | Electron
The most comprehensive tool to debug individual renderer processes is the Chromium Developer Toolset. It is available for all renderer processes, ...
Read more >
Electron - Debugging - Tutorialspoint
Debugging the Main Process. The DevTools in an Electron browser window can only debug JavaScript that is executed in that window (i.e., the...
Read more >
Debugging an Electron Application - Manning
Debugging the renderer process is relatively straight-forward. Electron's default application menu provides a command for opening the Chrome ...
Read more >
ElectronJS Tutorial - How to debug Electron JS in VS Code
ElectronJS Debugging can be irritating if you are forced to toggle between VS Code and Chrome Developer tools over and over.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found