microsoft / microsoft/node-api-dotnet
Electron JS app.quit() hang on Linux and Mac
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 783
- Forks
- 80
- PR merge metrics
- No merged PRs in 30d
Description
Hello,
If I use this technology in an Electron JS desktop application to load a C# AOT or .Net module then on Mac OS (and also Linux) the call to app.quit() hangs and the app does not closes normally, needing to do a force quit from Activity Monitor.
It happens with the simplest possible module found in your examples folder, as it is too much code I have made a demo app here:
[daniacedue/electron-nodeapi] (https://github.com/daniacedue/electron-nodeapi)
As a workaround I have tried brutally closing the process after some time or in the Electron's app.quit() handler by doing process.kill(process.pid, "SIGKILL"); but this is problematic because I need electron-updater npm package to be able to gracefully close in order to kick-off an update.
The problem is quite complex, I have also tried asking some chatbots to figure out what is happening by interpreting some stack traces and spindumps and it has something to do with low-level NAPI calls freezing the main process when doing the cleanup.
I have tried numerous "black box" possible fixes from both C# and JS (like explicit "destroy" function triggering dispose pattern because I was doubting the finalizers being the culpit) but without success.
Thanks!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the hang with the simplest module in the repository's examples folder and the linked daniacedue/electron-nodeapi demo. Start at Electron's app.quit() path and the .NET/C# AOT module cleanup, comparing behavior on macOS and Linux. Done means the app exits gracefully after loading the module, allowing electron-updater to start an update without force-killing the process.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, electron, javascript
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100