-
Notifications
You must be signed in to change notification settings - Fork 62
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
Change: use tree-kill #122
Conversation
Thanks for your PR! |
Yes, tree-kill kills the subprocesses of electron main. |
Does this happen often? Not sure there is a good benefit from introducing |
There's a issue to do tree-kill in node, but it's closed: nodejs/node#40438 |
Once again, thank you for the PR. export default defineConfig({
plugins: [
electron({
entry: 'electron/main.ts',
onstart: options => {
import('tree-kill').then(({ default: kill }) => kill(process.electronApp.pid!))
options.startup(['.', '--no-sandbox'])
},
}),
],
}) |
Okay! But I don't like to add tree-kill to the required dependencies, like vite-plugin-electron-renderer package.json {
"peerDependencies": {
"vite-plugin-electron-renderer": "*",
+ "tree-kill": "*"
},
"peerDependenciesMeta": {
"vite-plugin-electron-renderer": {
"optional": true
},
+ "tree-kill": {
+ "optional": true
+ }
}
} src/index.ts startup.exit = async () => {
if (process.electronApp) {
process.electronApp.removeAllListeners()
try {
const { default: treeKill } = await import('tree-kill')
treeKill(process.electronApp.pid!)
} catch (error) {
process.electronApp.kill()
}
}
} Would you mind making some changes? 😄 cc @shuyuTech, thanks you for explaining this issue. 👍 |
Done. |
wtf |
Managed to open again. |
你好,我是用js的,dev有时候,electron启动不起来。 然后随便修改下无关代码,重新dev,又能起来。不知道什么原因。 |
把 tree-kill 去掉试试先,这副作用真的 yue 🤮 |
没注意,原来是vite-plugin-electron里面添加了tree-kill,是可以在哪来设置可以关掉吗? |
我调试了代码 dev 的时候 , 会自动打包, 然后会启动一个closeBundle , 然后我console了, 你可以看我后面贴的代码. closeBundle() { |
哈哈,感谢你的提醒。 |
我也遇到一样的问题
我是监听 ready-to-show 事件启动 window 的,但在 dev 环境下,经常不触发这个事件。 |
This PR makes this plugin use
tree-kill
, which kills child processes.