microsoft / vscode-recipes

MIT License
5.86k stars 577 forks source link

Nodemon setup for Electron Applications (renderer and main) #262

Closed wapenshaw closed 2 years ago

wapenshaw commented 4 years ago

Hello!

I want to setup my debugging so that whenever nodemon restarts the app my vscode can debug both renderer and main processes. I have tried various things,

  1. Launching nodemon via terminal and attaching debuggers for renderer and main using compounds -- This however works partially as nodemon restarts the node debugger reattaches fine but the chrome debugger never does reattach itself to the process.
  2. Launching both debuggers from VScode, almost similar issues with chrome debugger.

Is there anyway I can attach and restart both node and chrome debuggers when nodemon restarts the app?

"restart": true, works for node debugger but not for chrome debugger as you can't use that property in its config.

here is my failed attempt to get it working.

    "configurations": [
        /*      {
            "type": "node",
            "request": "launch",
            "name": "Electron-Main",
            "protocol": "inspector",
            "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron",
            "runtimeArgs": [, "."],
            "windows": {
                "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron.cmd"
            }
        }, */
        /*      {
            "type": "node",
            "request": "launch",
            "name": "Electron-NPM",
            "runtimeExecutable": "nodemon",
            "runtimeArgs": [
                "--exec",
                "${workspaceFolder}/node_modules/.bin/electron.cmd --remote-debugging-port=9223 ."
            ],
            "port": 9223,
            "skipFiles": ["<node_internals>/**"],
            "restart": true,
            "outputCapture": "std"
        }, */
        {
            "type": "node",
            "request": "attach",
            "name": "Electron-NPM",
            "processId": "${command:PickProcess}",
            "restart": true,
            "protocol": "inspector"
        },
        {
            "name": "Electron-Renderer",
            "type": "chrome",
            "request": "attach",
            "port": 9223,
            "webRoot": "${workspaceFolder}",
            "timeout": 5000
        }
    ],
    "compounds": [
        {
            "name": "Electron: All",
            "configurations": ["Electron-NPM", "Electron-Renderer"]
        }
    ]

Any suggestions/workarounds appreciated!

connor4312 commented 2 years ago

Since July 2020 we have a new javascript debugger which supports restart in chrome attachment 🙂