electron: app.requestSingleInstanceLock doesnt work for signed mas builds (Mac App Store)
- Output of
node_modules/.bin/electron --version: 3.0.10 - Operating System (Platform and Version): MacOS Mojave 10.14.1
Expected Behavior Following code in index.js should not quit app:
let mainInstance = app.requestSingleInstanceLock()
if (!mainInstance) {
app.quit()
}
Actual behavior App quits.
Additional Information This problem does not occur for unsigned mas builds, only for signed.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 16
- Comments: 17 (4 by maintainers)
Commits related to this issue
- Revert instance lock change Makes app immediately quit for MAS build, see bug https://github.com/electron/electron/issues/15958 — committed to samuelmeuli/mini-diary by samuelmeuli 5 years ago
- Enhancements to make it Mac App Store (mas) compatible - disable the autoupdater if running as mas (was not working anyway, just logging an error on every start) - replace check via app.requestSingle... — committed to csett86/jitsi-meet-electron by csett86 3 years ago
- Enhancements to make it more Mac App Store (mas) compatible - disable the autoupdater if running as mas (was not working anyway, just logging an error on every start) - replace check via app.requestS... — committed to jitsi/jitsi-meet-electron by csett86 3 years ago
- https://github.com/electron/electron/issues/15958: multiple instances in electron 12x for mac workaround. Added back mas target. — committed to qcif/data-curator by deleted user 3 years ago
- https://github.com/electron/electron/issues/15958: multiple instances in electron 12x for mac workaround. Added back mas target. — committed to qcif/data-curator by deleted user 3 years ago
- Enhancements to make it more Mac App Store (mas) compatible - disable the autoupdater if running as mas (was not working anyway, just logging an error on every start) - replace check via app.requestS... — committed to d3473r/jitsi-meet-electron by csett86 3 years ago
@Slapbox you can use
to detect mas builds
Had the same issue that Apple rejected due to the reason “App quits on launch”.
Not the best practice, but used
process.platformin order to runapp.requestSingleInstanceLock()only on other platforms but Mac. Which of course fixed the problem, and Apple approved the app.It wasn’t worth the stress and time to make it work for Mac on my end since the OS already doesn’t let users run the app more than once. And starting the app via command line is tricky for ordinary users anyway.
But in the long term, hopefully this issue gets fixed so
app.requestSingleInstanceLock()plays nicely with the MAS build.Ultimately, my solution was to add
<key>LSMultipleInstancesProhibited</key>to the plist, tested in mas, it worked as expectedSame as this #15304