electron: app.quit() can't terminate electron.exe in 'ready' event handler without any window created
The minimal test case:
package.json :
{
"main": "quit-test.js",
"name": "quit-test",
"description": "quit-test",
"version": "0.1.0"
}
quit-test.js :
var app = require('app');
app.on('ready', function () {
console.log('ev:app ready');
app.quit();
console.log('after app.quit()');
});
app.on('quit', function () {
console.log('ev:app quit');
});
app.on('will-quit', function () {
console.log('ev:app will-quit');
});
Console output:
[804:0723/203017:INFO:CONSOLE(0)] ev:app ready
[804:0723/203017:INFO:CONSOLE(0)] ev:app will-quit
[804:0723/203017:INFO:CONSOLE(0)] ev:app quit
[804:0723/203017:INFO:CONSOLE(0)] after app.quit()
After the “quit” event, there are still two electron.exe process listed in Windows task manager, and I have to kill them forcibly.
Tested with electron-v0.30.0-win32-ia32 on Windows 7 64bit.
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Reactions: 1
- Comments: 21 (5 by maintainers)
Running into the same issue with 0.34.x. Closing from terminal does not kill the app, I have to do an
app.quit()from my tray menu in order to kill the process.EDIT, I ended up solving the issue by doing the following:
I have a
.on('close')listener that does a.preventDefault()and only hides the window, so that is why I had to do a.removeAllListeners('close')prior to closing the window.The issue still here with
0.36.7.Looks like this is a solution, thanks, guys!
I am quite new to Electron and I have packaged my app using electron-builder however when I quit the app, the instances are running (3 each time I run), I wrote a bat to terminate them manually but that’s silly having to clicking a bat file to taskkill the instances, here is my app main.js taken fromelectron template ,modified to have a splash:
main.zip Any suggestion on how to solve the problem?
For me, the problem still exists with a packed app, even when using
app.on('window-all-closed', app.quit);. But, it works when the app isn’t packed yet.I’m having the same problem 😮
Is this issue closed?
I have the same problem, can´t quit my application. OS: Windows 8.1 64bits Node: v6.10.3 Electron: v1.6.10
Reproducable with the initial post steps.
Thanks
@reza7rm I second this, I’m having the same issue with anything I do with electron on win7, its been a pretty big problem for me to have to either restart every time (or painfully manually remove them)
Do you happen to have a copy of the bat I could use for now?
When you are running your app using something like
electron main.jsit is running a default app wrapper that registers awindow-all-closedlistener, https://github.com/electron/electron/blob/0caa35d33ca61a263f26f86f789a29a1d7ef5aa9/default_app/main.js#L40-L44