fix(main): force hard exit on app close to prevent zombie processes#4
Open
hennring wants to merge 1 commit into
Open
fix(main): force hard exit on app close to prevent zombie processes#4hennring wants to merge 1 commit into
hennring wants to merge 1 commit into
Conversation
- Replaced graceful with definitive to ensure all 3 Chromium/Node background tasks terminate instantly. - Removed deferred exit logic in favor of a reliable linear execution flow. - Added robust try/catch safety wrappers around NDI and plugin cleanup blocks to prevent unhandled exceptions from halting the exit sequence. - Forced native plugin termination using . Closes riskcapital#3 Signed-off-by: Henning Kĺoß <henningkloss@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When closing the application window, the Renderer process terminates, but the remaining Electron/Chromium background tasks (Main, GPU, and Network processes) stay alive in the system's Task Manager.
Because of the app's single-instance lock implementation, these lingering "zombie" processes silently block users from reopening the application unless they manually kill the tasks via Task Manager. Furthermore, this resource lock causes file-permission errors (
EPERM) during local build routines (npm run build:desktop).The root cause is that hardware-heavy operations (like Spout/NDI) or active plugin child processes occasionally block Electron's graceful
app.quit()lifecycle from successfully completing the event loop.Solution
This PR refactors the
cleanupAndQuit()function in the main process to ensure a guaranteed, unblockable application shutdown:app.quit()withapp.exit(0): Once the cleanup logic has run, this forces all 3 active Chromium/Node tasks to exit immediately, bypassing Electron's easily obstructed graceful closing routine.try/catchstatements. If a native addon throws an unhandled error or ifpluginsis undefined/null, the sequence will safely continue instead of crashing halfway through.SIGKILLto forcefully drop any active hardware or file handles.setTimeoutblock to maintain a clean, synchronous, and predictable linear execution flow.Linked Issues
Fixes #3
Testing Checklist
npm run build:desktopwithout encounteringEPERMfile-locking issues.