nwjs / nw.js

Call all Node.js modules directly from DOM/WebWorker and enable a new way of writing applications with all Web technologies.
https://nwjs.io
MIT License
40.34k stars 3.88k forks source link

The app will not exit after closed all windows if a longpolling js code running. #7277

Open zhsunlight opened 4 years ago

zhsunlight commented 4 years ago

Thanks for reporting an issue! Spend 60 seconds reading this...

  1. Before reporting, try reproducing against the latest version of NWJS.
  2. Issue tracker is only for bugs and feature requests, in English only.

    Anything else? Use our mailing list for questions: https://groups.google.com/forum/#!forum/nwjs-general

======== TEMPLATE BUG FORM ========

NWJS Version : 0.43.1 Operating System : win10 64bit

Expected behavior

nwjs app exit after closed all windows.

Actual behavior

nwjs app didn't exit after closed all windows.

download 0.43.1 sdk, open nwjs, and open a page with longpolling javascript code running. and then open second window with the same page, then close all windows, the app will not exit.

zhsunlight commented 4 years ago

if set --disable-features=nw2, everythings will be right.

rogerwang commented 4 years ago

Could you please provide a full sample (not code snippets) so we can reproduce?

zhsunlight commented 4 years ago

Here it's. The app will open a link from an open source runbot website. Then login the website with Email (that is a user name) : admin, Password: admin. after login, right click in any space, then will popup a menu, then choose the 'New Window' menuitem, then will open another window with the same url from origin window. and last , close all the windows of this app. You can find in command line window, the app didn't quit at all.

If I set --disable-features=nw2, everything will be ok. If I don't login in the website ( the longpolling start only in login status), then right click an open another windown, then close all the windows of the app, the app will quit correctly. you can logout the website from the top right corner dropdown menu to simulate this situation.

nw2_longpolling_bug.zip

image image image image

rogerwang commented 4 years ago

Could you please provide a full sample (not code snippets) so we can reproduce?

zhsunlight commented 4 years ago

nw2_longpolling_bug.zip

This is a full sample. Do you need more other informations? Please tell me more details about what you need.

aliblackwell commented 4 years ago

Hello, I have been struggling with a very similar issue on Mac OSX Catalina 10.15.1 with NWJS 0.43.6 (latest). I had thought it was because I'm using a Node childProcess (similar to long polling) and in attempting to re-create it, I believe I've narrowed the bug down further.

I believe the issue described in the README of the project below is the same as the issue described above, and that long polling / childProcess is a red herring. If you show/hide windows launched from a main JS file, the standard App quit menu item stops working. A custom app quit button in a menu in a tray does work.

Contents of README.md of included example project:

When the app runs it will create a tray icon with two options: Settings + Quit App

Clicking Settings will open a window, causing the App Menu to appear. If you choose 'Quit nw2_demo' from the app menu it will close the window but not the tray or the background process.

Clicking 'Quit app' from the tray menu will quit the app properly.

For this sample project, --disable-features=nw2 does not resolve the issue.

nw2_quit_bug.zip

@rogerwang I believe if you manage to fix this it will resolve the long polling issue too. Many thanks!