#electron process not ending after window close

18 messages · Page 1 of 1 (latest)

humble wadi
#

Recently I have noticed that when exiting my electron app, I sometimes observe that it's processes are still running, when viewing my system monitor (testing on Linux Mint 21.3 mostly). I end up having to manually kill these processes to get another instance running properly.

Additionally I often debug using vscode, and after closing the main application window, I see the debugger stack trace remains (see screenshot).
If I press pause in the debugger i would expect it to show what stack frame it is busy executing to get an idea of why it doesn't exit, but pressing pause doesn't ever seem to do anything at this point.
Only pressing the debugger stop button actually ends the session. I could be mistaken, but I don't believe that was always the case, or that is how electron debugging is supposed to function?

I have tried adding the following to my main source file, but it didn't seem to make a difference:

  app.on('window-all-closed', function() {
    app.quit()
  })

Any ideas what is going on or how I can ensure that my app closes successfully?

humble wadi
#

Additional info about debug setup; launch.json:

{
  "version": "0.2.0",
  "configurations": [
      {
          "type": "node",
          "request": "launch",
          "name": "Electron Main",
          "runtimeExecutable": "npm",
          "runtimeArgs": ["run", "debug"],
          "cwd": "${workspaceFolder}",
          "stopOnEntry": false
      }
  ]
}

And in package.json:

"scripts": {
    "debug": "electron-forge start --inspect-electron -- --trace-warnings",
solar ferry
#

Does your app ever only ever have 1 window, or are you actually utilizing multiple windows?

humble wadi
#

only one window

solar ferry
humble wadi
#

no, but i set a breakpoint and verified that app.quit was actually being called.

#

via window-all-closed

solar ferry
#

Perhaps the window renderer process is still running, may be worth calling if(!window.isDestroyed()) window.destroy()

humble wadi
obtuse isle
#

while debugger is attached main process wont end

humble wadi
#

@obtuse isle ok, but is there any way to debug why the production release does not quit either?

humble wadi
#

GIF shows before/after closing the app window (processes filtered by app name). Only 1 of 8 processes actually ends. I don't know what any of these excess processes are doing.

obtuse isle
#

depends on what your app is doing

#

and what electron version you use

#

if vscode is closing properly then its not electron

#

or discord

humble wadi
#

downgrading to electron 28.3.1 causes the debugger to stop when window is closed as expected. Version 29.3.1 does not end process.

solar ferry