Electron-forge: --inspect-electron starts debugger, but does not pause at breakpoints (or debugger)

Created on 5 Sep 2018  路  4Comments  路  Source: electron-userland/electron-forge

Using [email protected] I'm seeing this with Chrome devtools/Node Inspector Manager. Is there an equivalent of node's --inspect-brk I can try?

Most helpful comment

Assuming your "start" command is literally "electron-forge start" you want to run this

yarn start -- -- --inspect-brk

To explain this, the first "--" passes arguments through from yarn to forge, the second "--" tells forge to pass all following arguments through from forge to electron.

All 4 comments

These kinds of questions should really go to the slack channel or community discourse, we aren't a support team 馃槃

but does not pause at breakpoints

Where are you setting these breakpoints

--inspect-brk

You should be able to launch with --inspect-brk yourself

we aren't a support team

Preamble stuff

I definitely appreciate that, but this feature doesn't seem to work for debugging scripts which have an end point, as opposed to scripts which run on an ongoing basis and might later hit a breakpoint. Nor does electron-forge seem to have an equivalent to the node's --inspect-brk.

I looked through the docs and the source code of the file that run the commands and the start command in particular: here & here

With that in mind, I figured it's safe to assume that this is not something that is going to be answered anywhere but here, even if I wait quite a while. It seems to be feature which doesn't exist, but perhaps should. Unfortunately I don't see any way to emulate without forking the entire project. At least not so far. I can't decipher where the final command is run and peel it out to run it myself with --inspect-brk. Before resorting to that I tried:

  • yarn start --inspect-brk
  • yarn start --inspect-brk-electron
  • node --inspect-brk ./node_modules/@electron-forge/cli/dist/electron-forge.js start (Seemed promising, but inspects electron-forge itself and never hits any of my files)

Recommendation

I would recommend adding an additional inspect-brk-electron argument and duplicating these lines with minor modifications:

https://github.com/electron-userland/electron-forge/blob/master/packages/api/core/src/api/start.ts

Duplicate and modify to be:

if (inspectBrk) {
  args = ['--inspect-brk' as (string|number)].concat(args);
}

Thoughts?


And whoops, to answer your questions:

I set breakpoints after the script had run, and then tried running the script again. The breakpoints are saved by the debugger, but not hit. I also tried straight up throwing debugger into my code, but it is also not hit. This is probably avoidable if I run some sort of a timeout before actually executing my code, but implementation of --inspect-brk-electron would be more desirable.

Assuming your "start" command is literally "electron-forge start" you want to run this

yarn start -- -- --inspect-brk

To explain this, the first "--" passes arguments through from yarn to forge, the second "--" tells forge to pass all following arguments through from forge to electron.

Damn! I tried one set of -- but didn't think to try two. Should have clicked when my other attempt resulted in debugging of electron-forge instead of my code. Thanks very much for setting me right.

Was this page helpful?
0 / 5 - 0 ratings