Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node process running after stopping app #96

Closed
pardahlman opened this issue Feb 11, 2018 · 14 comments
Closed

Node process running after stopping app #96

pardahlman opened this issue Feb 11, 2018 · 14 comments
Assignees
Milestone

Comments

@pardahlman
Copy link

Hello - I'm impressed by the great work in this project and I hope it will continue to evolve 👌. I'm playing around with a ASP.NET Core app, very similar to the demo app in this repo. When I stop the application after starting it from Visual Studio (Windows) there are still node process(es) running. I'm wondering if this is an known issue or if it is I who miss to make some call/dispose some resource in order to signal to Node that the web app has shut down.

Keep up the good work!

@AirLancer
Copy link

Sound a lot like this issue:
#68

@pardahlman
Copy link
Author

You are right @AirLancer - they are probably related. Worth noting is that I do this before shutting down the ASP.NET application

ElectronNET.API.Electron.App.Quit();

@Jonatthu
Copy link

I am still having this problem, Is there any solution?

@robertmuehsig
Copy link
Collaborator

I try to release a new version of the API as well - @GregorBiswanger told me, that there might be a fix included.

@GregorBiswanger
Copy link
Member

@pardahlman, @Jonatthu, @pardahlman - do you try out the newest version of API and CLI (0.0.9)?

@pardahlman
Copy link
Author

Hi, @GregorBiswanger - not yet (I didn't know it included a potential fix for this!). Will upgrade later today and report back to you. Thanks!

@pardahlman
Copy link
Author

0.0.9 is definitely more stable - thanks a bunch!

@flakron
Copy link

flakron commented Apr 16, 2018

I have version 0.0.9 and have this issue

@GregorBiswanger
Copy link
Member

@flakron What OS do you use?

@flakron
Copy link

flakron commented Apr 16, 2018

Sorry, should've left more information.

OS: Ubuntu 16.04,
Dotnet SDK version: 2.1.4

The backend doesn't seem to get that the windows is closed and keeps running in background.

@EldinZenderink
Copy link

EldinZenderink commented Jul 18, 2018


After running & closing 5 times using v0.0.9 . Backend does contain threads but I do know from earlier versions and standalone backend that they stop correctly when told so. I use both OnClose/OnClosed to close the threads running within the back-end.

A simple hack that i can think of is just literally starting a kill command for the back-end process... but that still doesn't tell electron to close.

Edit: welp, i gave up and went directly to main.js file, and adding this fixed it:

app.on('window-all-closed', app.quit);

app.on('before-quit', () => {
    apiProcess.kill();
});

@GregorBiswanger GregorBiswanger added this to the 0.0.10 milestone Sep 25, 2018
@robertmuehsig robertmuehsig modified the milestones: 0.0.10, 0.0.12 Jan 1, 2019
@GregorBiswanger
Copy link
Member

Fixed with the next Electron.NET update.

@netpoetica
Copy link

netpoetica commented Jun 3, 2019

FWIW, I am still seeing this error.

I have a main menu where the user clicks File -> Exit (I only have 1 window)

        public void FileExit()
        {
            Console.WriteLine("File exit");
            var mainWindow = Electron.WindowManager.BrowserWindows.First();
            mainWindow.Close();
        }

And then I have an event listener which is attached the app first starts:

            Electron.App.WindowAllClosed += () =>
            {
                Console.WriteLine("All windows closed");
                Electron.IpcMain.RemoveAllListeners("EventListItem.Click");
                Electron.IpcMain.RemoveAllListeners("JsonEditor.Save");
                Electron.App.Quit();
            };

I am taking extra care to manually remove all event listeners to ensure this isn't the reason why it fails.

What happens is, the window closes, and the electron process goes away, but the API process remains in the task manager (Activity Monitor on Mac OSX).

This is happening after a /target macosx release using the release version, and with electronize start.

It looks to me like the Click callback to MenuItem with name "exit" is not being called, maybe

       public void FileExit()
        {
            Console.WriteLine("File exit");
            var mainWindow = Electron.WindowManager.BrowserWindows.First();
            mainWindow.Close();
        }

        public void RenderMainMenu()
        {
            Console.WriteLine("Rendering main menu...");
            var menu = new MenuItem[]
            {
                new MenuItem
                {
                    Label = "File",
                    Submenu = new MenuItem[]
                    {
                        new MenuItem
                        {
                            Label = "Test File Menu",
                            Click = () => Console.WriteLine("Test menu item clicked.") 
                        },
                        new MenuItem
                        {
                            Label = "Exit",
                            Role = MenuRole.close,
                            Click = () =>
                            {
                                Console.WriteLine("Exiting program...");
                                FileExit();
                            }
                        }
                    }
                },

This console.log does not occur. If I rename "Exit" to "Go Away", the Click handler does get called, window closes, but the application remains open

@netpoetica
Copy link


After running & closing 5 times using v0.0.9 . Backend does contain threads but I do know from earlier versions and standalone backend that they stop correctly when told so. I use both OnClose/OnClosed to close the threads running within the back-end.

A simple hack that i can think of is just literally starting a kill command for the back-end process... but that still doesn't tell electron to close.

Edit: welp, i gave up and went directly to main.js file, and adding this fixed it:

app.on('window-all-closed', app.quit);

app.on('before-quit', () => {
    apiProcess.kill();
});

Can you share where that variable "app" came from in your site.js?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants