Hanging Electron process after running tests #1026

Closed
opened 2026-01-29 16:55:34 +00:00 by claunia · 13 comments
Owner

Originally created by @agracio on GitHub (Dec 6, 2025).

This is likely related to the issue that we get 3 idle processes if .NET side throws an exception, but slightly different.
I have a hanging electron.exe process for each integration test run, is there something we can do about them?

Originally created by @agracio on GitHub (Dec 6, 2025). This is likely related to the issue that we get 3 idle processes if .NET side throws an exception, but slightly different. I have a hanging electron.exe process for each integration test run, is there something we can do about them?
Author
Owner

@softworkz commented on GitHub (Dec 6, 2025):

I have a hanging electron.exe process for each integration test run, is there something we can do about them?

How does it happen? Any tests failing? Do you debug the tests? Or do you stop them at some point?

@softworkz commented on GitHub (Dec 6, 2025): > I have a hanging electron.exe process for each integration test run, is there something we can do about them? How does it happen? Any tests failing? Do you debug the tests? Or do you stop them at some point?
Author
Owner

@agracio commented on GitHub (Dec 6, 2025):

This happens when I use Resharper test runner in IDE - not sure if you have Resharper installed in your VS instance, when tests are running from dotnet test the 4 instances that get created during the run do close correctly.
Probably a Resharper runner issue.

As for the 3 idle processes that are left hanging when .net encounters exception it is very easy to reproduce - open demo app and try using Auto Update. There is an unhandled null reference exception in that code that crashes .net side of Electron.NET resulting in Socket disconnect. This means that closing the app does not close 3 Electron instances running in the background.

@agracio commented on GitHub (Dec 6, 2025): This happens when I use Resharper test runner in IDE - not sure if you have Resharper installed in your VS instance, when tests are running from `dotnet test` the 4 instances that get created during the run do close correctly. Probably a Resharper runner issue. As for the 3 idle processes that are left hanging when .net encounters exception it is very easy to reproduce - open demo app and try using Auto Update. There is an unhandled null reference exception in that code that crashes .net side of Electron.NET resulting in Socket disconnect. This means that closing the app does not close 3 Electron instances running in the background.
Author
Owner

@softworkz commented on GitHub (Dec 6, 2025):

I always use the VS test integration (even though I have R# installed).

You may perhapt need to disable parallel test exection for R#...?

There is an unhandled null reference exception in that code that crashes .net side of Electron.NET resulting in Socket disconnect.

That's an issue in the demo app, not in Electron.NET. An unhandled exception is an application bug.

@softworkz commented on GitHub (Dec 6, 2025): I always use the VS test integration (even though I have R# installed). You may perhapt need to disable parallel test exection for R#...? > There is an unhandled null reference exception in that code that crashes .net side of Electron.NET resulting in Socket disconnect. That's an issue in the demo app, not in Electron.NET. An unhandled exception is an application bug.
Author
Owner

@agracio commented on GitHub (Dec 6, 2025):

That's an issue in the demo app, not in Electron.NET. An unhandled exception is an application bug.

Yes and no, it just demonstrates that any unhandled exception can disconnect Electron.NET from the backend and it is not visible to the end user since the application does remain responsive to some interactions that do not go to backend.

@agracio commented on GitHub (Dec 6, 2025): > That's an issue in the demo app, not in Electron.NET. An unhandled exception is an application bug. Yes and no, it just demonstrates that any unhandled exception can disconnect Electron.NET from the backend and it is not visible to the end user since the application does remain responsive to some interactions that do not go to backend.
Author
Owner

@agracio commented on GitHub (Dec 6, 2025):

As for R# there does not appear to be a way to disable parallel running, so I will treat it as R# bug/feature.

@agracio commented on GitHub (Dec 6, 2025): As for R# there does not appear to be a way to disable parallel running, so I will treat it as R# bug/feature.
Author
Owner

@softworkz commented on GitHub (Dec 6, 2025):

When you develop a .net application, then it is your responsibility to make sure that no unhandled exception happen. Any librararies you use have nothing to do with that.

@softworkz commented on GitHub (Dec 6, 2025): When you develop a .net application, then it is your responsibility to make sure that no unhandled exception happen. Any librararies you use have nothing to do with that.
Author
Owner

@softworkz commented on GitHub (Dec 6, 2025):

demonstrates that any unhandled exception can disconnect Electron.NET from the backend and it is not visible to the end user since the application does remain responsive to some interactions that do not go to backend.

For such reasons, in earlier .net versions, applications always exited when there was an unhandled exception. It was changed later for other reasons (there are good reasons for either), but what hasn't changed is that normally, an unhandled exception means that the application state has become invalid.

@softworkz commented on GitHub (Dec 6, 2025): > demonstrates that any unhandled exception can disconnect Electron.NET from the backend and it is not visible to the end user since the application does remain responsive to some interactions that do not go to backend. For such reasons, in earlier .net versions, applications always exited when there was an unhandled exception. It was changed later for other reasons (there are good reasons for either), but what hasn't changed is that normally, an unhandled exception means that the application state has become invalid.
Author
Owner

@agracio commented on GitHub (Dec 6, 2025):

Of course you need to handle exceptions properly in your applications, the only issue I see is that in this case it leaves 3 orphan electron processes every time it fails.
It is not a huge deal but maybe there is a way to do something about it.
Anyway since the original issue turned out to be R# I will close it.

@agracio commented on GitHub (Dec 6, 2025): Of course you need to handle exceptions properly in your applications, the only issue I see is that in this case it leaves 3 orphan electron processes every time it fails. It is not a huge deal but maybe there is a way to do something about it. Anyway since the original issue turned out to be R# I will close it.
Author
Owner

@softworkz commented on GitHub (Dec 6, 2025):

maybe there is a way to do something about it.

Sure - you can start swallowing exceptions - but this way, your aren't doing any favor to the application developer, because they might never get to know about certain problems in their app, then.

@softworkz commented on GitHub (Dec 6, 2025): > maybe there is a way to do something about it. Sure - you can start swallowing exceptions - but this way, your aren't doing any favor to the application developer, because they might never get to know about certain problems in their app, then.
Author
Owner

@agracio commented on GitHub (Dec 6, 2025):

That is not what I meant, when there is a .net exception and front end of Electron.NET disconnects from backend there are 3 orphaned electron.exe processes that are left behind.
Closing Electron.NET app leaves them just hanging, with another 3 spawned when you open another instance of Electron.NET app.

@agracio commented on GitHub (Dec 6, 2025): That is not what I meant, when there is a .net exception and front end of Electron.NET disconnects from backend there are 3 orphaned electron.exe processes that are left behind. Closing Electron.NET app leaves them just hanging, with another 3 spawned when you open another instance of Electron.NET app.
Author
Owner

@softworkz commented on GitHub (Dec 6, 2025):

front end of Electron.NET disconnects from backend

What exactly do you mean by frontend and backend?

@softworkz commented on GitHub (Dec 6, 2025): > front end of Electron.NET disconnects from backend What exactly do you mean by frontend and backend?
Author
Owner

@agracio commented on GitHub (Dec 6, 2025):

There is a .net frontend or your UI for that matter that is visible to the user it runs Sockets to connect to the underlying electron.exe with Typescript implementation which is what I would call a backend. That electron.exe is where you send all of your Socket commands to and and expect response.
When you close your app you send a command using Sockets to close electron.exe that is listening to your requests.
In case of .net exception it completely disconnects the two and the underlying electron.exe will continue listening to requests on whatever port it has launched, it will never close. The underlying Electron process spawns 3 electron.exe instances which is very common with Electron and those instances will be hanging indefinitely when .net part closes abruptly.

@agracio commented on GitHub (Dec 6, 2025): There is a .net frontend or your UI for that matter that is visible to the user it runs Sockets to connect to the underlying electron.exe with Typescript implementation which is what I would call a backend. That electron.exe is where you send all of your Socket commands to and and expect response. When you close your app you send a command using Sockets to close electron.exe that is listening to your requests. In case of .net exception it completely disconnects the two and the underlying electron.exe will continue listening to requests on whatever port it has launched, it will never close. The underlying Electron process spawns 3 electron.exe instances which is very common with Electron and those instances will be hanging indefinitely when .net part closes abruptly.
Author
Owner

@softworkz commented on GitHub (Dec 6, 2025):

I'll try to respond tomorrow. Can't type that much anymore and dinner is 1 min away :-)

@softworkz commented on GitHub (Dec 6, 2025): I'll try to respond tomorrow. Can't type that much anymore and dinner is 1 min away :-)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Electron.NET#1026