nw.App.quit() does nothing when app has no windows
See original GitHub issueAppears in nwjs-sdk-v0.13.0-beta2-win-x64, probably others.
However, when I tried to reproduce this case in ubuntu, I’ve just ended up having app.js
raw source code in window. Cant find issue for that and probably won’t create some, because there are nothing particular in the docs about using *.js
files as main entry point.
SO, the problem itself:
When using JS file as app.main and the code does not generate any window, there isn’t possible to quit an application. Sample code follows.
// package.json:
{
"name": "nwtst",
"main": "app.js"
}
// app.js:
alert(Date.now());
nw.App.quit(); // well, process.exit(); just crashes nwjs at all
Expected result: show an alert, then have process ended.
Actual result: alert shown, but process persists in a task manager and application can’t be launched again until nw process killed manually (well, single-instance
can be set to false
whilst this feature has been deprecated now; and it’s not an option at all).
Workaround: after trying some various code samples (including process.exit();
) I realized that it may be caused by something that waits for all of app’s windows to be destroyed in App.quit()
, but that code never hits just because nodody can generate those events at all. So, adding nw.Window.open('', { show: false });
somewhere in app makes it exit as expected.
Issue Analytics
- State:
- Created 8 years ago
- Comments:8 (3 by maintainers)
Top GitHub Comments
This issue appears to still exist for me in
nw@0.23.6-sdk-1
. In an app that only has a tray,nw.App.quit();
had no effect until I added thew.Window.open('', { show: false });
workaround.still not fixed (0.36.1)