Skip to content

fix: Quit & Reopen still silently ate the relaunch (attempt 3) - #16

Merged
Alfredoalv13 merged 1 commit into
mainfrom
fix/relaunch-wait-for-exit
Jul 24, 2026
Merged

fix: Quit & Reopen still silently ate the relaunch (attempt 3)#16
Alfredoalv13 merged 1 commit into
mainfrom
fix/relaunch-wait-for-exit

Conversation

@Alfredoalv13

Copy link
Copy Markdown
Owner

Summary

  • fix: relaunch button could silently quit without reopening #13 and fix: Quit & Reopen could silently quit without ever reopening #15 both attempted to fix "Quit & Reopen" silently quitting without reopening. Verified directly with temporary debug logging this session that fix: Quit & Reopen could silently quit without ever reopening #15's fix (release the single-instance lock, then spawn `open`, then `app.exit()`) still didn't work.
  • Root cause, confirmed via logging: macOS's `open` command, when the target app bundle is already running as an OS process, brings the existing instance to the front rather than launching a second one - this has nothing to do with Electron's own `requestSingleInstanceLock()`, which fix: Quit & Reopen could silently quit without ever reopening #15 correctly fixed but wasn't the whole story. Since this process is still alive (mid-teardown) at the moment `open` runs, open just re-activates it, and once it then calls `app.exit()`, nothing is left running at all.
  • Fix: since nothing can run in this process after `app.exit()`, the wait for "is the old process actually gone yet" has to happen in a separate, already-spawned, detached process. A tiny polling shell script (`while kill -0 ; do sleep 0.05; done; open `) does that.
  • Verified directly, 3/3 consecutive clicks, that the app reliably reopens every time with this approach (previous two attempts failed on the very first live test).

Test plan

  • `tsc --noEmit` clean
  • `npm test` - 94/94 files, 819/819 tests passing
  • Manual: verified directly with temporary debug logging (removed before this PR) that this reopens the app reliably across repeated clicks

Verified directly with debug logging that PR #15's fix (releaseSingleInstanceLock()
then spawn 'open' then app.exit()) still silently ate the relaunch: `open` on
an already-running regular app bundle brings the existing process to the
front rather than launching a second one, regardless of Electron's own lock
state. Since this process was still alive (just mid-teardown) at the moment
`open` ran, it just re-activated *this* dying process - which then exited
via app.exit(), leaving nothing running.

The old process being fully gone has to be true before `open` runs, and
nothing can execute in this process after app.exit() calls it, so the wait
has to live in a separate detached process. A tiny polling shell script
(`while kill -0 <this-pid>; do sleep; done; open <bundle>`) does that
reliably; verified directly (3/3) that this actually reopens the app every
time, unlike the previous two attempts.
@Alfredoalv13
Alfredoalv13 merged commit 3a9e8ef into main Jul 24, 2026
1 check passed
@Alfredoalv13
Alfredoalv13 deleted the fix/relaunch-wait-for-exit branch July 24, 2026 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants