Skip to content

fix: Quit & Reopen could silently quit without ever reopening - #15

Merged
Alfredoalv13 merged 1 commit into
mainfrom
fix/relaunch-single-instance-lock
Jul 24, 2026
Merged

fix: Quit & Reopen could silently quit without ever reopening#15
Alfredoalv13 merged 1 commit into
mainfrom
fix/relaunch-single-instance-lock

Conversation

@Alfredoalv13

Copy link
Copy Markdown
Owner

Summary

  • This app enforces `requestSingleInstanceLock()`: if a new process can't acquire it, it calls `app.quit()` immediately (see the check right after `requestSingleInstanceLock()` in `main.ts`).
  • Verified directly this session that this is what was silently eating the "Quit & Reopen" relaunch (from fix: relaunch via open instead of app.relaunch() so TCC grants are seen #11/fix: relaunch button could silently quit without reopening #13): the new process spawned via `open` would sometimes start up while the old process still held the lock, see "another instance is already running," and immediately quit itself - leaving neither process running, no window, no error.
  • fix: relaunch button could silently quit without reopening #13's fix (delaying `app.exit()` by 500ms) didn't actually address this - delaying exit only makes the old process hold the lock longer, which makes this race more likely to bite, not less.
  • Fix: explicitly call `app.releaseSingleInstanceLock()` before spawning the replacement process, so the new process can always acquire the lock regardless of exact timing between the two processes.

Test plan

  • `tsc --noEmit` clean
  • `npm test` - 94/94 files, 819/819 tests passing
  • Manual: click "Quit & Reopen" from the permission banner repeatedly (10+ times in a row) and confirm the app reliably reopens every single time, not just most of the time

This app enforces requestSingleInstanceLock() (main.ts: app.quit() runs
immediately if the lock can't be acquired). Verified directly this session
that this is what was silently eating the "Quit & Reopen" relaunch: if the
new process spawned via `open` starts up while this process still holds the
lock, it sees another instance already running and immediately quits itself
- so both the old and new process end up exited, and no window ever
reappears. PR #13's fix (delay before app.exit()) didn't address this since
delaying app.exit() only holds the lock longer, making the race worse rather
than avoiding it.

Explicitly release the lock before spawning the replacement process, so it
can always acquire it regardless of exact timing.
@Alfredoalv13
Alfredoalv13 merged commit ef45582 into main Jul 24, 2026
1 check passed
@Alfredoalv13
Alfredoalv13 deleted the fix/relaunch-single-instance-lock branch July 24, 2026 18:16
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