Skip to content
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

Debugging configuration, update readme, add sample debugging configurations. #505

Merged
merged 6 commits into from
May 4, 2020

Conversation

pm0u
Copy link
Contributor

@pm0u pm0u commented Apr 26, 2020

This PR adds sample debugging configurations under a dev/sample folder (would this be the proper/desired location?) and and ENV file that sets proper environment variables for the main process, and allows a remote debugging port to be passed to the renderer process.

Few gotchas:

  1. The launch for main provided doesn't always seem to connect in time to catch breakpoints in src/main/index.js. Sometimes it will, other times it seems to attach after this code has been executed.
  2. It is possible to use --inspect-brk=$PORT under ELECTRON_ARGS to break on the first line (and then ideally you could connect debugger before any code in src/main/index.js is executed)... but this seems to break on the first line of some internal electron process, rather than the app.

A workaround for these could be to throw a debugger; line in src/main/index.js if you need to debug that file, and then hopefully execution would sit until the debugger connects, unsure on that one.

3. The renderer process doesn't seem to map breakpoints within class components properly. (more reason to use functional components? 😄 ) Any breakpoint set within the component is mapped to the class declaration line, and then following execution leads to a rabbit hole of inner React modules. I am not sure how to get past this, and I couldn't find anything about this in searching.

Re: # 3 -- This seems to be related to HMR, if a refresh is forced once the app has opened (Ctrl + r), then breakpoints are mapped properly. Unsure why.

In VSCode it is also possible to launch with debug params in an external console (supposedly) but when i tried this, it just launched my terminal and never acutally launched the app within that terminal window. I think this would be ideal for the main process, rather than launching within VSCode's internal terminal (which can be hard to use).

Reference

electron-webpack env vars
debugging issue 1
debugging issue 2

Signed-off-by: Paul Mourer <paul.mourer@gmail.com>
Signed-off-by: Paul Mourer <paul.mourer@gmail.com>
Signed-off-by: Paul Mourer <paul.mourer@gmail.com>
Signed-off-by: Paul Mourer <paul.mourer@gmail.com>
Signed-off-by: Paul Mourer <paul.mourer@gmail.com>
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron-webpack",
"args": ["dev"],
"env": {
//"DEBUG":"*",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left this line commented as it may be useful. This outputs extremely verbose output from electron/electron-webpack.

"sourceMaps": true,
"smartStep": true,
"showAsyncStacks": true,
"timeout": 30000
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This timeout will vary, but it needs to be longer than the amount of time it takes for the electron app to launch so that VSCode does not give up. Perhaps i will note this..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

noted.

Signed-off-by: Paul Mourer <paul.mourer@gmail.com>
@pm0u pm0u marked this pull request as ready for review April 26, 2020 19:07
@pm0u pm0u changed the title [DRAFT] Debugging configuration, update readme, add sample debugging configurations. Debugging configuration, update readme, add sample debugging configurations. Apr 26, 2020
@obra
Copy link
Member

obra commented Apr 28, 2020

@algernon - go ahead and merge at your leisure, then :)

@algernon algernon merged commit db39c32 into keyboardio:master May 4, 2020
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.

3 participants