Repository navigation
Fix app not quitting when no child processes are running (macOS) - #215
Open
JulianGlueck wants to merge 1 commit into
Open
JulianGlueck wants to merge 1 commit into
JulianGlueck wants to merge 1 commit into
Conversation
Member
|
Good find! Thanks |
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
Since the
before-quithandler waits for child processes to exit, an app without any child processes (e.g.'queue_workers' => []) no longer quits on macOS. The windows close, but the app stays in the Dock. Clicking the Dock icon does nothing, because the PHP server has already been killed.Cause
Without running processes, the wait loop never awaits. So the final
app.quit()runs synchronously, while the outerbefore-quithandler is still running:app.quit()passesbefore-quit(this.quittingis alreadytrue). Electron marks the quit as accepted and starts closing the windows.preventDefault()ed, so Electron resets its quitting state.window-all-closed.On Windows and Linux, the same happens, but the
window-all-closedhandler callsapp.quit()again, which then goes through. So the symptom only shows on macOS, where the app deliberately stays open without windows.With at least one child process (e.g. a queue worker), the loop awaits once.
app.quit()then runs after the handler has returned, which is why this went unnoticed.Fix
Defer the final
app.quit()to the next tick withsetImmediate(). Then it always runs after the outer quit has finished, whether or not any processes are running.Steps to reproduce
'queue_workers' => []inconfig/nativephp.php(and don't start any other child processes).With this change, the app quits as expected.