question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
TylerRickcommented, Jul 19, 2017

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 the w.Window.open('', { show: false }); workaround.

0reactions
panther7commented, Feb 27, 2019

still not fixed (0.36.1)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Calling app.quit() in electron app does nothing in Windows ...
The app has a tray icon and menu with a quit button that calls electron.app.quit() const createTray = () => { const trayIconPath ......
Read more >
Apps not working after latest windows update
I installed the latest update a couple of days ago and since then most of my apps & programs in my start bar...
Read more >
Why Does Closing Windows on a Mac not Quit the Application?
https://macmost.com/e-2856 When switching from Windows to Mac many people wonder why Mac apps don't quit when you click the red close button ...
Read more >
How to Fix You'll Need a New App to Open This MS Windows ...
If you receive an error that reads "You'll Need a New App to Open This MS- Windows -Store," then there's a problem with...
Read more >
How To Fix Microsoft Store Not Downloading Apps ... - YouTube
Your browser can 't play this video. Learn more. Switch camera.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found