nw.js icon indicating copy to clipboard operation
nw.js copied to clipboard

nw.App.quit() does nothing when app has no windows

Open offshore opened this issue 10 years ago • 8 comments

Appears 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.

offshore avatar Jan 13 '16 15:01 offshore

I can confirm this bug with beta3.

ghostoy avatar Jan 14 '16 01:01 ghostoy

fixed in git and will be available in the next nightly build.

rogerwang avatar Jan 16 '16 14:01 rogerwang

Thanks.

offshore avatar Jan 18 '16 10:01 offshore

This issue appears to still exist for me in [email protected]. In an app that only has a tray, nw.App.quit(); had no effect until I added the w.Window.open('', { show: false }); workaround.

TylerRick avatar Jul 19 '17 19:07 TylerRick

Thanks your this issue, I also encountered this situation.

TongDaDa avatar Jan 15 '19 12:01 TongDaDa

I can reproduce this with nwjs-sdk-v0.36.0-beta1-win-x64 (and nwjs-sdk-v0.35.5-win-x64). I use the sample code above and the results and workaround are exactly the same as above.

ffanny avatar Jan 19 '19 08:01 ffanny

I also have this problem on 0.35.5 SDK x64

suns-echoes avatar Jan 28 '19 13:01 suns-echoes

still not fixed (0.36.1)

panther7 avatar Feb 27 '19 19:02 panther7