Skip to content

Commit 15b6fc6

Browse files
committed
chore(vscode-debugger): update debugger on main process
1 parent e91f934 commit 15b6fc6

5 files changed

Lines changed: 34 additions & 133 deletions

File tree

README.md

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -57,43 +57,15 @@ Use this to quickly open and switch VS Code projects.
5757
8. [fixed] close the packaged app via cmd+q seems not close SwitchV-server-macos process? check by command: lsof -i:55688. Use ctrl+c to stop development (running via yarn start) is OK. (add close button on tray to help? I guess it is not helping).
5858
1. Solved by electron sending kill server process in the before-quick event handler. Another person suggests to add one more step to handle SIGINT signal on server side, ref https://stackoverflow.com/questions/71523442/child-process-doesnt-exit.
5959

60-
### debugger issue
60+
### Use VS Code Debugger
6161

6262
**To debug main process**
6363

64-
Below is a workaround way to debug main process: Its reference is
65-
https://github.com/electron-userland/electron-forge/issues/1369#issuecomment-1172913835
66-
64+
In VS Code Run and Debug, choose `Electron: Main Process` to launch and debug.
6765

68-
```json
69-
{
70-
"type": "node",
71-
"request": "launch",
72-
"name": "Electron Main",
73-
"runtimeExecutable": "npm",
74-
"runtimeArgs": [
75-
"run",
76-
"start",
77-
],
78-
"cwd": "${workspaceFolder}"
79-
}
80-
```
81-
82-
electron-forge official site only mention how to debug main process but it has a bug
83-
https://github.com/electron-userland/electron-forge/issues/1369
84-
85-
```json
86-
{
87-
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron-forge-vscode-nix",
88-
}
89-
```
90-
91-
Error: Cannot find module '/Users/liamdawson/w/@electron-forge/cli/dist/electron-forge-start'
92-
93-
94-
**To debug render process (workaround way)**
66+
**To debug render process (below set up becomes broken after the timing updating electron 29 and add 2nd window, please directly set up breakpoints in the opened dev tool instead) **
9567

96-
[electron site](https://www.electronjs.org/docs/latest/tutorial/debugging-vscode) and [ms github site](https://github.com/Microsoft/vscode-recipes/tree/master/Electron) both mention below setting to debug main proces
68+
~~[electron site](https://www.electronjs.org/docs/latest/tutorial/debugging-vscode) and [ms github site](https://github.com/Microsoft/vscode-recipes/tree/master/Electron) both mention below setting to debug main proces
9769

9870

9971
```json
@@ -107,7 +79,7 @@ and ms github site has a extra setting for debugging render process. But the abo
10779
1. `yarn start` (to start webpack server part)
10880
2. launch compound "Electron: All" launch setting (from ms github site) to debug main & **render processes**.
10981

110-
The drawback is you will see two copy of SwitchV. And attaching render process takes a little time (e.g. only stop at some breakpoints after a while/refresh).
82+
The drawback is you will see two copy of SwitchV. And attaching render process takes a little time (e.g. only stop at some breakpoints after a while/refresh).~~
11183

11284
## notes about packaging a macOS app
11385

electron/.vscode/launch.json

Lines changed: 26 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
{
22
"version": "0.2.0",
33
"configurations": [
4+
{
5+
"name": "Electron: Main Process",
6+
"type": "node",
7+
"request": "launch",
8+
"cwd": "${workspaceFolder}",
9+
"runtimeExecutable": "yarn",
10+
"windows": {
11+
"runtimeExecutable": "yarn.cmd"
12+
},
13+
"runtimeArgs": [
14+
"start"
15+
],
16+
"outputCapture": "std",
17+
},
418
{
519
"name": "Debug Current File",
620
"type": "node",
@@ -11,68 +25,34 @@
1125
]
1226
},
1327
{
14-
"name": "Electron: Main Process",
1528
"type": "node",
1629
"request": "launch",
17-
"cwd": "${workspaceFolder}",
18-
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron-forge-vscode-win",
19-
"windows": {
20-
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron-forge-vscode-win.cmd"
21-
},
22-
"args" : [
30+
"name": "Electron: ms-Main-blank-only-used-in-comound",
31+
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron",
32+
"runtimeArgs": [
2333
".",
24-
"--remote-debugging-port=9223"
34+
"--remote-debugging-port=9223",
2535
],
26-
"outputCapture": "std",
27-
"console": "integratedTerminal",
28-
"sourceMaps": true,
29-
"resolveSourceMapLocations": [
30-
"${workspaceFolder}/**",
31-
"!**/node_modules/**"
32-
],
33-
"preLaunchTask": "npm: start",
34-
"env": {
35-
"NODE_ENV": "development"
36-
}
37-
},
38-
{
39-
"name": "Electron: Renderer Process",
40-
"type": "chrome",
41-
"request": "attach",
42-
"port": 9223,
43-
"webRoot": "${workspaceFolder}",
44-
"timeout": 30000,
45-
"urlFilter": "*main_window*",
46-
"sourceMapPathOverrides": {
47-
"webpack:///./~/*": "${workspaceFolder}/node_modules/*",
48-
"webpack:///./*": "${workspaceFolder}/*",
49-
"webpack:///*": "*"
36+
"windows": {
37+
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron.cmd"
5038
}
5139
},
5240
{
53-
"name": "Electron: Explainer Renderer Process",
41+
"name": "Electron: ms-Renderer-only-used-in-comound",
5442
"type": "chrome",
5543
"request": "attach",
5644
"port": 9223,
5745
"webRoot": "${workspaceFolder}",
58-
"timeout": 30000,
59-
"urlFilter": "*explainer_window*",
60-
"sourceMapPathOverrides": {
61-
"webpack:///./~/*": "${workspaceFolder}/node_modules/*",
62-
"webpack:///./*": "${workspaceFolder}/*",
63-
"webpack:///*": "*"
64-
}
46+
"timeout": 30000
6547
}
6648
],
6749
"compounds": [
6850
{
69-
"name": "Electron: All Processes",
51+
"name": "Electron: All(require manually run start first)",
7052
"configurations": [
71-
"Electron: Main Process",
72-
"Electron: Renderer Process",
73-
"Electron: Explainer Renderer Process"
74-
],
75-
"stopAll": true
53+
"Electron: ms-Main-blank-only-used-in-comound",
54+
"Electron: ms-Renderer-only-used-in-comound"
55+
]
7656
}
7757
]
7858
}

electron/.vscode/tasks.json

Lines changed: 0 additions & 33 deletions
This file was deleted.

electron/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
"make-x86": "electron-forge make --arch=x64 --platform=darwin",
2020
"publish": "electron-forge publish",
2121
"lint": "eslint --ext .ts,.tsx .",
22-
"db:migrate": "prisma migrate dev"
22+
"db:migrate": "prisma migrate dev",
23+
"watch": "webpack --watch"
24+
2325
},
2426
"keywords": [],
2527
"author": {

extension/.vscode/tasks.json

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)