Node process running after stopping app #120

Closed
opened 2026-01-29 16:31:32 +00:00 by claunia · 14 comments
Owner

Originally created by @pardahlman on GitHub (Feb 11, 2018).

Originally assigned to: @GregorBiswanger on GitHub.

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!

Originally created by @pardahlman on GitHub (Feb 11, 2018). Originally assigned to: @GregorBiswanger on GitHub. 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!
claunia added the bugIn progress labels 2026-01-29 16:31:32 +00:00
Author
Owner

@AirLancer commented on GitHub (Feb 11, 2018):

Sound a lot like this issue:
https://github.com/ElectronNET/Electron.NET/issues/68

@AirLancer commented on GitHub (Feb 11, 2018): Sound a lot like this issue: https://github.com/ElectronNET/Electron.NET/issues/68
Author
Owner

@pardahlman commented on GitHub (Feb 17, 2018):

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();
@pardahlman commented on GitHub (Feb 17, 2018): You are right @AirLancer - they are probably related. Worth noting is that I do this before shutting down the ASP.NET application ```cs ElectronNET.API.Electron.App.Quit(); ```
Author
Owner

@Jonatthu commented on GitHub (Feb 18, 2018):

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

@Jonatthu commented on GitHub (Feb 18, 2018): I am still having this problem, Is there any solution?
Author
Owner

@robertmuehsig commented on GitHub (Feb 19, 2018):

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

@robertmuehsig commented on GitHub (Feb 19, 2018): I try to release a new version of the API as well - @GregorBiswanger told me, that there might be a fix included.
Author
Owner

@GregorBiswanger commented on GitHub (Feb 25, 2018):

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

@GregorBiswanger commented on GitHub (Feb 25, 2018): @pardahlman, @Jonatthu, @pardahlman - do you try out the newest version of API and CLI (0.0.9)?
Author
Owner

@pardahlman commented on GitHub (Feb 26, 2018):

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 commented on GitHub (Feb 26, 2018): 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!
Author
Owner

@pardahlman commented on GitHub (Mar 21, 2018):

0.0.9 is definitely more stable - thanks a bunch!

@pardahlman commented on GitHub (Mar 21, 2018): 0.0.9 is definitely more stable - thanks a bunch!
Author
Owner

@flakron commented on GitHub (Apr 16, 2018):

I have version 0.0.9 and have this issue

@flakron commented on GitHub (Apr 16, 2018): I have version 0.0.9 and have this issue
Author
Owner

@GregorBiswanger commented on GitHub (Apr 16, 2018):

@flakron What OS do you use?

@GregorBiswanger commented on GitHub (Apr 16, 2018): @flakron What OS do you use?
Author
Owner

@flakron commented on GitHub (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.

@flakron commented on GitHub (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.
Author
Owner

@EldinZenderink commented on GitHub (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();
});
@EldinZenderink commented on GitHub (Jul 18, 2018): ![](https://i.imgur.com/8nwDOxm.png) 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(); });
Author
Owner

@GregorBiswanger commented on GitHub (May 18, 2019):

Fixed with the next Electron.NET update.

@GregorBiswanger commented on GitHub (May 18, 2019): Fixed with the next Electron.NET update.
Author
Owner

@netpoetica commented on GitHub (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 commented on GitHub (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
Author
Owner

@netpoetica commented on GitHub (Jun 3, 2019):


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?

@netpoetica commented on GitHub (Jun 3, 2019): > ![](https://camo.githubusercontent.com/ee8dbf3f81a27fd42a121f5e58763edcd619d3a7/68747470733a2f2f692e696d6775722e636f6d2f386e77444f786d2e706e67) > 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 in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Electron.NET#120