Skip to content

Fixes for VSCode Debug in Windows #3692

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

JackGlobetrotter
Copy link

@JackGlobetrotter JackGlobetrotter commented Apr 28, 2025

As mentioned in multiple issues, debugging has not been working well in VSCode neither for for Main and Renderer processes.
This fixes these issues, thus closing: #3689 #3472

It proposes the following changes:

  • Creating multiple launch configurations according to current setup in the start script in package.json
    • Electron: Pre launches a new script called start:VSCode witch is similar to start but does not include npm run start:renderer
    • Electron: Renderer start the start:renderer:VSCode script
      • launches new webpack config file (webpack.config.renderer.dev.vscode.ts), similar to previous webpack.config.renderer.dev.ts, which does not launch start:main as this seems to prevents debugging in VSCode
    • Electron: Main start the start:main script, which enables debugging breakpoints for VSCode
    • Electron: Renderer Attach starts as before attaching to port 9223
  • Edit in main.ts to enable remote debugging port
    let port = '9223';
    if (process.env.MAIN_ARGS) {
      if (process.env.MAIN_ARGS) {
         port = (([...process.env.MAIN_ARGS.matchAll(/"[^"]+"|[^\s"]+/g)]
         .flat()
        .filter(str=>str.includes('debugging-port'))[0]||"=9223").split('=')[1])
      } 
    }
    app.commandLine.appendSwitch("remote-debugging-port", port)
    

ATTENTION: This config has only been tested in VSCode running on Win11! More testing is definitely needed! And it should be tested in different environments before merging!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant